/*
Navicat MySQL Data Transfer
Source Server : locahost
Source Server Version : 50087
Source Host : localhost:3306
Source Database : gov
Target Server Type : MYSQL
Target Server Version : 50087
File Encoding : 65001
Date: 2015-06-25 11:13:14
drop database if exists gov;
create database gov;
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `comment`
-- ----------------------------
DROP TABLE IF EXISTS `comment`;
CREATE TABLE `comment` (
`id` int(11) NOT NULL auto_increment,
`title` varchar(32) NOT NULL COMMENT '意见反馈标题',
`content` text NOT NULL COMMENT '意见反馈内容',
`contactEmail` varchar(20) NOT NULL COMMENT '反馈人的联系方式',
`createTime` datetime NOT NULL,
`status` int(11) NOT NULL COMMENT '标记评论是否已经有回复,0为待处理,1为讨论中,2为关闭讨论,3为假删除',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of comment
-- ----------------------------
-- ----------------------------
-- Table structure for `image`
-- ----------------------------
DROP TABLE IF EXISTS `image`;
CREATE TABLE `image` (
`id` int(11) NOT NULL auto_increment,
`newsId` int(11) NOT NULL,
`location` varchar(32) NOT NULL,
PRIMARY KEY (`id`),
KEY `newsId` (`newsId`),
CONSTRAINT `image_ibfk_1` FOREIGN KEY (`newsId`) REFERENCES `news` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of image
-- ----------------------------
-- ----------------------------
-- Table structure for `news`
-- ----------------------------
DROP TABLE IF EXISTS `news`;
CREATE TABLE `news` (
`id` int(11) NOT NULL auto_increment,
`title` varchar(32) NOT NULL COMMENT '新闻标题',
`content` text NOT NULL,
`type` int(11) NOT NULL COMMENT '一共8类信息:0公告;1等等待完善',
`createTime` datetime default NULL,
`userId` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `userId` (`userId`),
CONSTRAINT `news_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of news
-- ----------------------------
-- ----------------------------
-- Table structure for `reply`
-- ----------------------------
DROP TABLE IF EXISTS `reply`;
CREATE TABLE `reply` (
`id` int(11) NOT NULL auto_increment,
`content` text NOT NULL,
`commentId` int(11) NOT NULL,
`createTime` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `commentId` (`commentId`),
CONSTRAINT `reply_ibfk_1` FOREIGN KEY (`commentId`) REFERENCES `comment` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of reply
-- ----------------------------
-- ----------------------------
-- Table structure for `user`
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(11) NOT NULL auto_increment,
`username` varchar(20) NOT NULL,
`password` varchar(32) NOT NULL,
`email` varchar(20) NOT NULL,
`phone` char(11) NOT NULL,
`role` int(11) NOT NULL COMMENT '1为管理员,2为发布员,3为反馈员',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES ('1', 'admin', 'admin', 'zzuhtzy@163.com', '1100fsadf', '1');
INSERT INTO `user` VALUES ('2', 'ferweqrwe', 'fdsfas', 'rqwer', '1100rewqr', '1');
INSERT INTO `user` VALUES ('4', 'HHHHHHH', 'fasdf', 'fasdf', 'fdasf', '2');
INSERT INTO `user` VALUES ('5', 'fdsaf', 'dsaf', 'fdsaf', 'fdasf', '2');
INSERT INTO `user` VALUES ('6', 'admin', 'fdasf', 'zzuhtzy@163.com', '1100fsadf', '1');
INSERT INTO `user` VALUES ('7', 'fdasf', 'fdsasf', 'fdassf', 'fadsf', '2');
INSERT INTO `user` VALUES ('8', '453fda', '432fsd', '432fds', '43sdf', '2');
INSERT INTO `user` VALUES ('9', 'fdasf', '432fd', 'fsd', '432', '2');
INSERT INTO `user` VALUES ('10', 'admin', '342sdf', 'zzuhtzy@163.com', '1100fsadf', '1');
INSERT INTO `user` VALUES ('14', '22222', '2222', '222', '2222', '2');
INSERT INTO `user` VALUES ('15', 'bdfds', 'fsadfsdf', 'fasdfsadf', 'fdsafsadf', '2');
INSERT INTO `user` VALUES ('16', '3333', '3333', '3333', '3333', '3');
-- ----------------------------
-- Table structure for `vote`
-- ----------------------------
DROP TABLE IF EXISTS `vote`;
CREATE TABLE `vote` (
`id` int(11) NOT NULL auto_increment,
`newsId` int(11) NOT NULL,
`createTime` datetime NOT NULL,
`endTime` datetime NOT NULL,
`state` int(11) NOT NULL COMMENT '投票的状态',
PRIMARY KEY (`id`),
KEY `newsId` (`newsId`),
CONSTRAINT `vote_ibfk_1` FOREIGN KEY (`newsId`) REFERENCES `news` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of vote
-- ----------------------------
-- ----------------------------
-- Table structure for `voteitem`
-- ----------------------------
DROP TABLE IF EXISTS `voteitem`;
CREATE TABLE `voteitem` (
`id` int(11) NOT NULL auto_increment,
`content` text NOT NULL,
`voteId` int(11) NOT NULL,
`num` int(11) NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `voteId` (`voteId`),
CONSTRAINT `voteitem_ibfk_1` FOREIGN KEY (`voteId`) REFERENCES `vote` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of voteitem
Navicat MySQL Data Transfer
Source Server : locahost
Source Server Version : 50087
Source Host : localhost:3306
Source Database : gov
Target Server Type : MYSQL
Target Server Version : 50087
File Encoding : 65001
Date: 2015-06-25 11:13:14
*/
一般需要下面的三行!
drop database if exists gov;
create database gov;
use gov;
也可使用下面的语句
CREATE DATABASE IF NOT EXISTS `gov` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `gov`;
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `comment`
-- ----------------------------
DROP TABLE IF EXISTS `comment`;
CREATE TABLE `comment` (
`id` int(11) NOT NULL auto_increment,
`title` varchar(32) NOT NULL COMMENT '意见反馈标题',
`content` text NOT NULL COMMENT '意见反馈内容',
`contactEmail` varchar(20) NOT NULL COMMENT '反馈人的联系方式',
`createTime` datetime NOT NULL,
`status` int(11) NOT NULL COMMENT '标记评论是否已经有回复,0为待处理,1为讨论中,2为关闭讨论,3为假删除',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of comment
-- ----------------------------
-- ----------------------------
-- Table structure for `image`
-- ----------------------------
DROP TABLE IF EXISTS `image`;
CREATE TABLE `image` (
`id` int(11) NOT NULL auto_increment,
`newsId` int(11) NOT NULL,
`location` varchar(32) NOT NULL,
PRIMARY KEY (`id`),
KEY `newsId` (`newsId`),
CONSTRAINT `image_ibfk_1` FOREIGN KEY (`newsId`) REFERENCES `news` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of image
-- ----------------------------
-- ----------------------------
-- Table structure for `news`
-- ----------------------------
DROP TABLE IF EXISTS `news`;
CREATE TABLE `news` (
`id` int(11) NOT NULL auto_increment,
`title` varchar(32) NOT NULL COMMENT '新闻标题',
`content` text NOT NULL,
`type` int(11) NOT NULL COMMENT '一共8类信息:0公告;1等等待完善',
`createTime` datetime default NULL,
`userId` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `userId` (`userId`),
CONSTRAINT `news_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of news
-- ----------------------------
-- ----------------------------
-- Table structure for `reply`
-- ----------------------------
DROP TABLE IF EXISTS `reply`;
CREATE TABLE `reply` (
`id` int(11) NOT NULL auto_increment,
`content` text NOT NULL,
`commentId` int(11) NOT NULL,
`createTime` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `commentId` (`commentId`),
CONSTRAINT `reply_ibfk_1` FOREIGN KEY (`commentId`) REFERENCES `comment` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of reply
-- ----------------------------
-- ----------------------------
-- Table structure for `user`
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(11) NOT NULL auto_increment,
`username` varchar(20) NOT NULL,
`password` varchar(32) NOT NULL,
`email` varchar(20) NOT NULL,
`phone` char(11) NOT NULL,
`role` int(11) NOT NULL COMMENT '1为管理员,2为发布员,3为反馈员',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES ('1', 'admin', 'admin', 'zzuhtzy@163.com', '1100fsadf', '1');
INSERT INTO `user` VALUES ('2', 'ferweqrwe', 'fdsfas', 'rqwer', '1100rewqr', '1');
INSERT INTO `user` VALUES ('4', 'HHHHHHH', 'fasdf', 'fasdf', 'fdasf', '2');
INSERT INTO `user` VALUES ('5', 'fdsaf', 'dsaf', 'fdsaf', 'fdasf', '2');
INSERT INTO `user` VALUES ('6', 'admin', 'fdasf', 'zzuhtzy@163.com', '1100fsadf', '1');
INSERT INTO `user` VALUES ('7', 'fdasf', 'fdsasf', 'fdassf', 'fadsf', '2');
INSERT INTO `user` VALUES ('8', '453fda', '432fsd', '432fds', '43sdf', '2');
INSERT INTO `user` VALUES ('9', 'fdasf', '432fd', 'fsd', '432', '2');
INSERT INTO `user` VALUES ('10', 'admin', '342sdf', 'zzuhtzy@163.com', '1100fsadf', '1');
INSERT INTO `user` VALUES ('14', '22222', '2222', '222', '2222', '2');
INSERT INTO `user` VALUES ('15', 'bdfds', 'fsadfsdf', 'fasdfsadf', 'fdsafsadf', '2');
INSERT INTO `user` VALUES ('16', '3333', '3333', '3333', '3333', '3');
-- ----------------------------
-- Table structure for `vote`
-- ----------------------------
DROP TABLE IF EXISTS `vote`;
CREATE TABLE `vote` (
`id` int(11) NOT NULL auto_increment,
`newsId` int(11) NOT NULL,
`createTime` datetime NOT NULL,
`endTime` datetime NOT NULL,
`state` int(11) NOT NULL COMMENT '投票的状态',
PRIMARY KEY (`id`),
KEY `newsId` (`newsId`),
CONSTRAINT `vote_ibfk_1` FOREIGN KEY (`newsId`) REFERENCES `news` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of vote
-- ----------------------------
-- ----------------------------
-- Table structure for `voteitem`
-- ----------------------------
DROP TABLE IF EXISTS `voteitem`;
CREATE TABLE `voteitem` (
`id` int(11) NOT NULL auto_increment,
`content` text NOT NULL,
`voteId` int(11) NOT NULL,
`num` int(11) NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `voteId` (`voteId`),
CONSTRAINT `voteitem_ibfk_1` FOREIGN KEY (`voteId`) REFERENCES `vote` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of voteitem
-- ----------------------------
http://blog.csdn.net/u011630575/article/details/49255719