当前位置:网站首页>项目:数据库表的梳理
项目:数据库表的梳理
2022-08-02 14:10:00 【鱼子酱:P】
总共4张表---发私信功能未实现,所以只有用户表、登录凭证表、帖子表、评论表四张。
1.user用户表
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) DEFAULT NULL,
`password` varchar(50) DEFAULT NULL,
`salt` varchar(50) DEFAULT NULL,
`email` varchar(100) DEFAULT NULL,
`type` int(11) DEFAULT NULL COMMENT '0-普通用户; 1-超级管理员; 2-版主;',
`status` int(11) DEFAULT NULL COMMENT '0-未激活; 1-已激活;',
`activation_code` varchar(100) DEFAULT NULL,
`header_url` varchar(200) DEFAULT NULL,
`create_time` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_username` (`username`(20)),
KEY `index_email` (`email`(20))
) ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=utf8;
- username用户名称
- password用户密码
- salt盐用来加密
- email用户的邮箱
- type用户的类型 0表示普通用户 1表示超级管理员 2表示版主
- status 0表示未激活 1表示激活
- activation_code激活码
- header_url头像地址
- create_time用户注册时间
2.discuss_post帖子表
CREATE TABLE `discuss_post` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` varchar(45) DEFAULT NULL,
`title` varchar(100) DEFAULT NULL,
`content` text,
`type` int(11) DEFAULT NULL COMMENT '0-普通; 1-置顶;',
`status` int(11) DEFAULT NULL COMMENT '0-正常; 1-精华; 2-拉黑;',
`create_time` timestamp NULL DEFAULT NULL,
`comment_count` int(11) DEFAULT NULL,
`score` double DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- user_id表示发帖人的id
- title表示标题
- content表示帖子内容
- type表示帖子类型 0表示普通帖子 1表示置顶帖子
- status表示帖子的状态 0表示正常帖子 1表示精华帖 2表示拉黑帖
- create_time表示发帖日期
- comment_count表示帖子的评论数,是一个冗余参数,目的是为了提供查询效率
3.login_ticket登录凭证表
CREATE TABLE `login_ticket` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`ticket` varchar(45) NOT NULL,
`status` int(11) DEFAULT '0' COMMENT '0-有效; 1-无效;',
`expired` timestamp NOT NULL,
PRIMARY KEY (`id`),
KEY `index_ticket` (`ticket`(20))
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
登录凭证表,目的是为了保护用户数据的安全,用于检测用户是否处于登录状态,然后在启动服务器时通过拦截器获取登录凭证创建User对象
- user_id用户id
- ticket凭证编号
- status凭证状态 0表示有效凭证 1表示无效凭证
- expired用于检测这个凭证是否已经过期
4.comment评论表
CREATE TABLE `comment` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) DEFAULT NULL,
`entity_type` int(11) DEFAULT NULL,
`entity_id` int(11) DEFAULT NULL,
`target_id` int(11) DEFAULT NULL,
`content` text,
`status` int(11) DEFAULT NULL,
`create_time` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_user_id` (`user_id`) /*!80000 INVISIBLE */,
KEY `index_entity_id` (`entity_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- user_id用于表示发这条评论的用户id
- entity_type表示评论的类型 :1表示回复帖子的评论 2表示回复评论的评论
- entity_id表示该评论的帖子id
- target_id表示回复时回复对象的id,如果id=0说明这是一条回复帖子的评论,如果id!=0说明这是回复target_id用户的评论
- content评论内容
- status评论的状态0表示有用的评论 1表示以删除的评论
- create_time评论的发表时间
5.message消息表
CREATE TABLE `message` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`from_id` int(11) DEFAULT NULL,
`to_id` int(11) DEFAULT NULL,
`conversation_id` varchar(45) NOT NULL,
`content` text,
`status` int(11) DEFAULT NULL COMMENT '0-未读;1-已读;2-删除;',
`create_time` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `index_from_id` (`from_id`),
KEY `index_to_id` (`to_id`),
KEY `index_conversation_id` (`conversation_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
- from_id是发消息的人的id
- to_id是发送目标的人的id
- conversation_id也是一个冗余的字段目的是便于查询,规则以from_id和to_id用_拼接且小的在前大的在后
- content消息内容
- status消息的状态 0表示未读 1表示已读 2表示删除
- create_time消息的发送时间
边栏推荐
- 系统线性、时不变、因果判断
- jest test, component test
- LeetCode2 电话号码的字母组合
- Win7怎么干净启动?如何只加载基本服务启动Win7系统
- A clean start Windows 7?How to load only the basic service start Windows 7 system
- PHY6222蓝牙5.2支持MESH组网M0内核超低功耗
- Win10无法连接打印机怎么办?不能使用打印机的解决方法
- 发布模块到npm应该怎么操作?及错误问题解决方案
- Win10系统设置application identity自动提示拒绝访问怎么办
- DP4344兼容CS4344-DA转换器
猜你喜欢
Open the door of power and electricity "Circuit" (2): Power Calculation and Judgment
How to add a one-key shutdown option to the right-click menu in Windows 11
MATLAB绘图命令fimplicit绘制隐函数图形入门详解
Mysql连接错误解决
Open the door to electricity "Circuit" (3): Talk about different resistance and conductance
STM32LL库——USART中断接收不定长信息
The SSE instructions into ARM NEON
13.56MHZ刷卡芯片CI521兼容cv520/ci520支持A卡B卡MIFARE协议
How to set the win10 taskbar does not merge icons
Binder机制(中篇)
随机推荐
Golang 垃圾回收机制详解
pygame绘制弧线
CMAKE
Win10上帝模式干嘛的?Win10怎么开启上帝模式?
基于最小二乘法的线性回归分析方程中系数的估计
Win11 keeps popping up User Account Control how to fix it
MATLAB制作简易小动画入门详解
How to update Win11 sound card driver?Win11 sound card driver update method
jest test, component test
单端K总线收发器DP9637兼容L9637
GMP scheduling model of golang
Spark及相关生态组件安装配置——快速回忆
ECP2459耐压60V降压BUCK电路用于WIFI模块供电方案原理图
镜像法求解接地导体空腔电势分布问题
Win11没有本地用户和组怎么解决
vscode镜像
Yolov5 official code reading - prior to transmission
13.56MHZ刷卡芯片CI521兼容cv520/ci520支持A卡B卡MIFARE协议
2.4G无线小模块CI24R1超低成本
Win11声卡驱动如何更新?Win11声卡驱动更新方法