数据库设计
<h1>数据库设计</h1>
<h2>用户表-users</h2>
<table>
<thead>
<tr>
<th><em>列名</em></th>
<th><em>要求</em></th>
<th><em>说明</em></th>
</tr>
</thead>
<tbody>
<tr>
<td>uid</td>
<td>自动增长</td>
<td>唯一标识,区分用户</td>
</tr>
<tr>
<td>username</td>
<td>不能为空,唯一</td>
<td>用户名</td>
</tr>
<tr>
<td>password</td>
<td>不能为空</td>
<td>密码 </td>
</tr>
<tr>
<td>email</td>
<td>可以为空</td>
<td>用户邮箱</td>
</tr>
<tr>
<td>state</td>
<td>1在线0下线,默认0</td>
<td>用户状态</td>
</tr>
<tr>
<td>rid</td>
<td>不能为空,默认为用户的角色id</td>
<td>角色id</td>
</tr>
</tbody>
</table>
<h2>用户属性-userattr</h2>
<table>
<thead>
<tr>
<th><em>列名</em></th>
<th><em>要求</em></th>
<th><em>说明</em></th>
</tr>
</thead>
<tbody>
<tr>
<td>uid</td>
<td>唯一标识</td>
<td>绑定users表uid主外键关联</td>
</tr>
<tr>
<td>headimg</td>
<td>可重复,字符类型</td>
<td>用户头像,网络地址</td>
</tr>
<tr>
<td>spageview</td>
<td>范围要大</td>
<td>总浏览量、自己帖子浏览量改变时也要改变</td>
</tr>
<tr>
<td>usposts</td>
<td>不能为空,默认为0</td>
<td>用户帖子总数</td>
</tr>
<tr>
<td>age</td>
<td>不能为空,默认1</td>
<td>账号年龄,创建账号距离现在的天数</td>
</tr>
<tr>
<td>attention</td>
<td>不能为空,默认为0</td>
<td>我关注的人</td>
</tr>
<tr>
<td>fans</td>
<td>不能为空,默认为0</td>
<td>关注我的人</td>
</tr>
<tr>
<td>friend</td>
<td>不能为空,默认为0,用,隔开</td>
<td>好友id</td>
</tr>
</tbody>
</table>
<p><font color="red">userattr表uid(外键)关联 users表uid(主键)</font></p>
<h2>管理员表-admins</h2>
<table>
<thead>
<tr>
<th><em>列名</em></th>
<th><em>要求</em></th>
<th><em>说明</em></th>
</tr>
</thead>
<tbody>
<tr>
<td>aid</td>
<td>自动增长</td>
<td>管理员id,唯一标识</td>
</tr>
<tr>
<td>ausername</td>
<td>不能为空,唯一</td>
<td>账号</td>
</tr>
<tr>
<td>apassword</td>
<td>不能为空</td>
<td>密码</td>
</tr>
</tbody>
</table>
<p><font color="red">admin表aid(外键)关联 roles表rid(主键)</font></p>
<h2>角色表-roles</h2>
<table>
<thead>
<tr>
<th><em>列名</em></th>
<th><em>要求</em></th>
<th><em>说明</em></th>
</tr>
</thead>
<tbody>
<tr>
<td>rid</td>
<td>自动增长,唯一</td>
<td>角色id,唯一标识</td>
</tr>
<tr>
<td>rolename</td>
<td>不能为空</td>
<td>角色名</td>
</tr>
<tr>
<td>rpower</td>
<td>多个权限id用,隔开</td>
<td>角色拥有的权限id</td>
</tr>
</tbody>
</table>
<h2>权限表-powers</h2>
<table>
<thead>
<tr>
<th><em>列名</em></th>
<th><em>要求</em></th>
<th><em>说明</em></th>
</tr>
</thead>
<tbody>
<tr>
<td>powerid</td>
<td>自动增长</td>
<td>权限id,唯一标识</td>
</tr>
<tr>
<td>powername</td>
<td>不能为空,唯一</td>
<td>权限名</td>
</tr>
</tbody>
</table>
<h2>帖子表-posts</h2>
<table>
<thead>
<tr>
<th><em>列名</em></th>
<th><em>要求</em></th>
<th><em>说明</em></th>
</tr>
</thead>
<tbody>
<tr>
<td>uid</td>
<td>不能为空</td>
<td>绑定users表uid主外键关联</td>
</tr>
<tr>
<td>pid</td>
<td>自动增长</td>
<td>唯一标识,区分帖子</td>
</tr>
<tr>
<td>sid</td>
<td>可重复</td>
<td>属于哪个版块</td>
</tr>
<tr>
<td>title</td>
<td>不能为空</td>
<td>标题</td>
</tr>
<tr>
<td>content</td>
<td>不能为空</td>
<td>内容 </td>
</tr>
<tr>
<td>pageview</td>
<td>范围要大,默认0</td>
<td>浏览量 </td>
</tr>
<tr>
<td>createdate</td>
<td>日期类型,不能为空</td>
<td>创建日期、修改帖子后也会改变</td>
</tr>
<tr>
<td>tags</td>
<td>字符类型,用,隔开</td>
<td>帖子标签</td>
</tr>
</tbody>
</table>
<p><font color="red">posts表uid(外键)关联 users表uid(主键)</font>
<font color="red">posts表pid(外键)关联 section表sid(主键)</font></p>
<h2>版块表-section</h2>
<table>
<thead>
<tr>
<th><em>列名</em></th>
<th><em>要求</em></th>
<th><em>说明</em></th>
</tr>
</thead>
<tbody>
<tr>
<td>sid</td>
<td>不能为空</td>
<td>唯一标识,版块id</td>
</tr>
<tr>
<td>sname</td>
<td>不能为空</td>
<td>唯一标识,版块名</td>
</tr>
<tr>
<td>sattention</td>
<td>默认为0</td>
<td>关注此版块的人数</td>
</tr>
<tr>
<td>screatedate</td>
<td>不能为空,默认为当前时间</td>
<td>版块创建日期</td>
</tr>
<tr>
<td>ssposts</td>
<td>不能为空,默认为0</td>
<td>版块下帖子总数</td>
</tr>
</tbody>
</table>
<h2>评论表-comment</h2>
<table>
<thead>
<tr>
<th><em>列名</em></th>
<th><em>要求</em></th>
<th><em>说明</em></th>
</tr>
</thead>
<tbody>
<tr>
<td>cid</td>
<td>int</td>
<td>评论id,唯一</td>
</tr>
<tr>
<td>uid</td>
<td>int</td>
<td>评论的用户id</td>
</tr>
<tr>
<td>pid</td>
<td>int</td>
<td>评论的帖子id</td>
</tr>
<tr>
<td>createdate</td>
<td>datatime</td>
<td>评论时间</td>
</tr>
<tr>
<td>content</td>
<td>longtext</td>
<td>评论的内容</td>
</tr>
</tbody>
</table>
<h2>回复表-reply</h2>
<table>
<thead>
<tr>
<th><em>列名</em></th>
<th><em>要求</em></th>
<th><em>说明</em></th>
</tr>
</thead>
<tbody>
<tr>
<td>cid</td>
<td>int</td>
<td>回复的评论id,用于查询评论的回复</td>
</tr>
<tr>
<td>uid</td>
<td>int</td>
<td>回复用户的id</td>
</tr>
<tr>
<td>content</td>
<td>longtext</td>
<td>回复的内容</td>
</tr>
<tr>
<td>createdate</td>
<td>datatime</td>
<td>回复的时间</td>
</tr>
</tbody>
</table>