搭建骑行社区
设计了我自己的数据库结构
CREATE TABLE `t_announce` ( `id` int(11) NOT NULL AUTO_INCREMENT, `announcement` longtext, `title` varchar(100) DEFAULT NULL, `newtime` datetime DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; CREATE TABLE `t_category` ( `id` int(11) NOT NULL, `name` varchar(30) DEFAULT NULL, `count_topics` int(11) DEFAULT '0', `count_comments` int(11) DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `t_comment` ( `id` int(11) NOT NULL AUTO_INCREMENT, `content` longtext, `floor` int(11) DEFAULT NULL, `comment_time` datetime DEFAULT NULL, `comments_user_id` int(11) NOT NULL, `comments_topic_id` int(11) NOT NULL, `integral` int(11) DEFAULT '0', `status` int(11) DEFAULT '0', PRIMARY KEY (`id`), KEY `comments_topic_id` (`comments_topic_id`) USING BTREE, KEY `comments_user_id` (`comments_user_id`), CONSTRAINT `comments_topic_id` FOREIGN KEY (`comments_topic_id`) REFERENCES `t_topic` (`id`), CONSTRAINT `comments_user_id` FOREIGN KEY (`comments_user_id`) REFERENCES `t_user` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=80 DEFAULT CHARSET=utf8; CREATE TABLE `t_grade` ( `id` int(11) NOT NULL AUTO_INCREMENT, `honor` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8; CREATE TABLE `t_help` ( `id` int(11) NOT NULL, `title` varchar(100) DEFAULT NULL, `content` longtext, `newtime` datetime DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `t_new` ( `id` int(11) NOT NULL AUTO_INCREMENT, `new_time` datetime DEFAULT NULL, `news_comment_user_id` int(11) NOT NULL, `news_topic_id` int(11) NOT NULL, `status` int(11) DEFAULT '0', PRIMARY KEY (`id`), KEY `news_comment_user_id` (`news_comment_user_id`), KEY `news_topic_id` (`news_topic_id`), CONSTRAINT `news_comment_user_id` FOREIGN KEY (`news_comment_user_id`) REFERENCES `t_user` (`id`), CONSTRAINT `news_topic_id` FOREIGN KEY (`news_topic_id`) REFERENCES `t_topic` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8; CREATE TABLE `t_topic` ( `id` int(11) NOT NULL, `title` varchar(50) DEFAULT NULL, `content` longtext, `comment_count` int(11) DEFAULT '0', `status` int(11) DEFAULT '0', `topic_time` datetime DEFAULT NULL, `topics_user_id` int(11) NOT NULL, `topics_type_id` int(11) NOT NULL, `nice_topic` int(11) DEFAULT '0', `integral` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `topics_user_id` (`topics_user_id`), KEY `topics_type_id` (`topics_type_id`), CONSTRAINT `topics_type_id` FOREIGN KEY (`topics_type_id`) REFERENCES `t_type` (`id`), CONSTRAINT `topics_user_id` FOREIGN KEY (`topics_user_id`) REFERENCES `t_user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `t_type` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(30) DEFAULT NULL, `count_topics` int(11) DEFAULT '0', `count_comments` int(11) DEFAULT '0', `is_admin_type` int(11) DEFAULT '0', `types_category_id` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `types_category_id` (`types_category_id`), CONSTRAINT `types_category_id` FOREIGN KEY (`types_category_id`) REFERENCES `t_category` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8; CREATE TABLE `t_user` ( `id` int(11) NOT NULL, `username` varchar(20) DEFAULT NULL, `password` varchar(20) DEFAULT NULL, `nickname` varchar(32) DEFAULT NULL, `sex` varchar(2) DEFAULT NULL, `picture` varchar(255) DEFAULT NULL, `email` varchar(20) DEFAULT NULL, `come_from` varchar(200) DEFAULT NULL, `introduction` longtext, `profession` varchar(40) DEFAULT NULL, `grade_integal` int(11) DEFAULT '0', `integral` int(11) DEFAULT NULL, `clock` int(11) DEFAULT NULL, `topic_count` int(11) DEFAULT NULL, `comment_count` int(11) DEFAULT NULL, `role_id` int(11) DEFAULT '0', `users_grade_id` int(11) NOT NULL, `register_time` datetime DEFAULT NULL, `status` int(11) DEFAULT '0', PRIMARY KEY (`id`), KEY `usersGrade_id` (`users_grade_id`), CONSTRAINT `usersGrade_id` FOREIGN KEY (`users_grade_id`) REFERENCES `t_grade` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;