当前位置:网站首页>项目:数据库表的梳理
项目:数据库表的梳理
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消息的发送时间
边栏推荐
- BLE蓝牙5.2-PHY6222系统级芯片(SoC)智能手表/手环
- MATLAB绘制平面填充图入门详解
- Letter combination of LeetCode2 phone number
- Please make sure you have the correct access rights and the repository exists. Problem solved
- 编译error D8021 :无效的数值参数“/Wextra” cl command line error d8021 invalid numeric argument ‘/wextra‘
- pytorch模型转libtorch和onnx格式的通用代码
- STM32LL库——USART中断接收不定长信息
- CS4398音频解码替代芯片DP4398完全兼容DAC解码
- 轻量化AlphaPose
- How to solve Win11 without local users and groups
猜你喜欢
随机推荐
Win7遇到错误无法正常开机进桌面怎么解决?
【系统设计与实现】基于flink的分心驾驶预测与数据分析系统
DP4301无线收发SUB-1G芯片兼容CC1101智能家居
What should I do if Windows 10 cannot connect to the printer?Solutions for not using the printer
设备驱动框架简介
系统线性、时不变、因果判断
Win10安装了固态硬盘还是有明显卡顿怎么办?
source /build/envsetup.sh和lunch)
golang之GMP调度模型
一篇文章彻底理解Redis的持久化:RDB、AOF
为vscode配置clangd
pygame draw arc
镜像法求解接地导体空腔电势分布问题
How to add a one-key shutdown option to the right-click menu in Windows 11
使用 腾讯云搭建一个个人博客
基于矩阵计算的线性回归分析方程中系数的估计
FP7122降压恒流内置MOS耐压100V共正极阳极PWM调光方案原理图
将SSE指令转换为ARM NEON指令
Flink + sklearn - use JPMML implement flink deployment on machine learning model
Daily - Notes









