当前位置:网站首页>Project: combing the database table
Project: combing the database table
2022-08-02 15:34:00 【Caviar :P】
A total of 4 tables---The function of sending private messages is not implemented, so there are only four tables: user table, login credential table, post table, and comment table.
1.user user table
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-normal user; 1-super administrator; 2-moderator;',`status` int(11) DEFAULT NULL COMMENT '0-inactive; 1-active;',`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;
- usernameusername
- passwordUser password
- The salt is used for encryption
- email user's mailbox
- type user type 0 means ordinary user 1 means super administrator 2 means moderator
- status 0 means inactive 1 means active
- activation_codeActivation code
- header_url avatar address
- create_time user registration time
2.discuss_post post table
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-normal; 1-top;',`status` int(11) DEFAULT NULL COMMENT '0-normal; 1-essence; 2-blackout;',`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 indicates the id of the poster
- title means title
- content indicates the content of the post
- type means post type 0 means normal post 1 means top post
- status means the status of the post 0 means normal post 1 means elite post 2 means blocked post
- create_time indicates the date of the post
- comment_count indicates the number of comments on the post, which is a redundant parameter to improve query efficiency
3.login_ticket login credentials table
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-valid; 1-invalid;',`expired` timestamp NOT NULL,PRIMARY KEY (`id`),KEY `index_ticket` (`ticket`(20))) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Login credential table, the purpose is to protect the security of user data, used to detect whether the user is logged in, and then obtain the login credentials through the interceptor to create a User object when the server is started
- user_iduserid
- ticket number
- status credential status 0 means valid credential 1 means invalid credential
- expired is used to check if the credential has expired
4.comment comment form
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 is used to indicate the id of the user who posted this comment
- entity_type indicates the type of comments: 1 means comments in response to posts 2 means comments in response to comments
- entity_id indicates the post id of the comment
- target_id indicates the id of the reply object when replying. If id=0, it means this is a comment replying to a post. If id!=0, it means this is a comment replying to target_id user
- contentComment content
- status comments with a status of 0 for helpful comments and 1 for deleted comments
- When the create_time comment was posted
5.message message table
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-unread;1-read;2-delete;',`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 is the id of the person who sent the message
- to_id is the id of the person sending the target
- conversation_id is also a redundant field to facilitate query, the rules are spliced with from_id and to_id with _ and the smaller is in the front and the larger is in the back
- content message content
- The status of the status message 0 means unread 1 means read 2 means deleted
- The time when the create_time message was sent
边栏推荐
- 动态规划理论篇
- 关于c语言的调试技巧
- Win10电脑需要安装杀毒软件吗?
- jest test, component test
- Do Windows 10 computers need antivirus software installed?
- Win11电脑一段时间不操作就断网怎么解决
- 基于矩阵计算的线性回归分析方程中系数的估计
- [STM32 Learning 1] Basic knowledge and concepts are clear
- Win10系统设置application identity自动提示拒绝访问怎么办
- Win11 keeps popping up User Account Control how to fix it
猜你喜欢
随机推荐
How to add a one-key shutdown option to the right-click menu in Windows 11
Win10电脑不能读取U盘怎么办?不识别U盘怎么解决?
Win7遇到错误无法正常开机进桌面怎么解决?
二叉树创建之层次法入门详解
casbin模型
质数相关问题-小记
基于最小二乘法的线性回归分析方程中系数的估计
Software Testing Basics (Back)
Daily - Notes
测试用例练习
推开机电的大门《电路》(一):电压,电流,参考方向
Win10 Settings screen out from lack of sleep?Win10 set the method that never sleep
Codeforces Round #624 (Div. 3)
Win11怎么在右键菜单添加一键关机选项
How to update Win11 sound card driver?Win11 sound card driver update method
轻量化AlphaPose
队列与栈
pygame图像连续旋转
win10怎么设置不睡眠熄屏?win10设置永不睡眠的方法
发布模块到npm应该怎么操作?及错误问题解决方案