总共4张表---发私信功能未实现,所以只有用户表、登录凭证表、帖子表、评论表四张。
- 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;
- 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;
- 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对象
- 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;
- 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;