Database Design

1, Create a new system configuration table

CREATE TABLE `sysconfig` (

`cid` int(11) NOT NULL auto_increment,

`vote_name` varchar(45 ) NOT NULL,

`dietime` date NOT NULL,

`method` int(11) NOT NULL default '1',

`description` varchar(800) NOT NULL default '',

PRIMARY KEY (`cid`)

) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

2, Create a new user table

CREATE TABLE `users` (

`cid` int(11) NOT NULL auto_increment,

`username` varchar(40) NOT NULL,

` passwd` varchar(45) NOT NULL,

`admin` int(11) NOT NULL default '0',

`isvote` int(11) NOT NULL default '0',

PRIMARY KEY (`cid`)

) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

3, Create a new voting question table

CREATE TABLE `votename` (

`cid` int(11) NOT NULL auto_increment,

`question_name` varchar(200) NOT NULL,

`votetype` int(11) NOT NULL default '0' COMMENT '0 is single selection\n1 is multiple selection',

`sumvotenum` int(11) NOT NULL default '1',

PRIMARY KEY (`cid `)

) ENGINE=MyISAM AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;

4, Create a new voting option table

CREATE TABLE `voteoption` (

`cid` int(11) NOT NULL auto_increment,

`optionname` varchar(100) NOT NULL default '',

`votenum` int(11) NOT NULL default '0',

`upid` int(11) NOT NULL,

PRIMARY KEY (`cid`,`upid`),

KEY `fk_voteoption_votename_idx` (`upid`)

) ENGINE=MyISAM AUTO_INCREMENT=50 DEFAULT CHARSET=utf8;

5,Add test data

INSERT INTO `sysconfig` VALUES ('1', 'Test', ' 2019-01-31', '1', 'Test test test test test test test test test test test test test test test test test');


Continuing Learning
||
<?php echo "数据库设计";
submitReset Code