1.项目结构
2.数据库设计
1 # MySQL-Front 5.0 (Build 1.0) 2 3 /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE */; 4 /*!40101 SET SQL_MODE=\'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\' */; 5 /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES */; 6 /*!40103 SET SQL_NOTES=\'ON\' */; 7 8 9 # Host: localhost Database: db_votemanage 10 # ------------------------------------------------------ 11 # Server version 5.0.67-community-nt 12 13 DROP DATABASE IF EXISTS `db_votemanage`; 14 CREATE DATABASE `db_votemanage` /*!40100 DEFAULT CHARACTER SET gb2312 */; 15 USE `db_votemanage`; 16 17 # 18 # Table structure for table tb_channel 19 # 20 21 CREATE TABLE `tb_channel` ( 22 `channelID` int(11) NOT NULL auto_increment, 23 `channelName` varchar(255) default NULL, 24 PRIMARY KEY (`channelID`) 25 ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=gb2312 COMMENT=\'投票频道表\'; 26 INSERT INTO `tb_channel` VALUES (1,\'NBA\'); 27 INSERT INTO `tb_channel` VALUES (2,\'CBA\'); 28 INSERT INTO `tb_channel` VALUES (3,\'足球世界杯\'); 29 INSERT INTO `tb_channel` VALUES (4,\'中超\'); 30 INSERT INTO `tb_channel` VALUES (5,\'英超\'); 31 INSERT INTO `tb_channel` VALUES (6,\'F1\'); 32 33 # 34 # Table structure for table tb_vote 35 # 36 37 CREATE TABLE `tb_vote` ( 38 `voteID` int(11) NOT NULL auto_increment, 39 `voteName` varchar(255) default NULL, 40 `channelID` int(11) default NULL, 41 PRIMARY KEY (`voteID`), 42 KEY `channelID` (`channelID`) 43 ) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=gb2312 COMMENT=\'投票表\'; 44 INSERT INTO `tb_vote` VALUES (13,\'请选择你最喜欢的CBA球员\',2); 45 46 # 47 # Table structure for table tb_voteoption 48 # 49 50 CREATE TABLE `tb_voteoption` ( 51 `voteOptionID` int(11) NOT NULL auto_increment, 52 `voteID` int(11) default NULL, 53 `voteOptionName` varchar(255) default NULL, 54 `ticketNum` int(11) default \'0\', 55 PRIMARY KEY (`voteOptionID`), 56 KEY `voteID` (`voteID`) 57 ) ENGINE=InnoDB AUTO_INCREMENT=55 DEFAULT CHARSET=gb2312 COMMENT=\'投票选项表\'; 58 INSERT INTO `tb_voteoption` VALUES (51,13,\'朱芳宇\',0); 59 INSERT INTO `tb_voteoption` VALUES (52,13,\'王治郅\',1); 60 INSERT INTO `tb_voteoption` VALUES (53,13,\'姚明\',0); 61 INSERT INTO `tb_voteoption` VALUES (54,13,\'易建联\',0); 62 63 # 64 # Foreign keys for table tb_vote 65 # 66 67 ALTER TABLE `tb_vote` 68 ADD CONSTRAINT `tb_vote_ibfk_1` FOREIGN KEY (`channelID`) REFERENCES `tb_channel` (`channelID`); 69 70 # 71 # Foreign keys for table tb_voteoption 72 # 73 74 ALTER TABLE `tb_voteoption` 75 ADD CONSTRAINT `tb_voteoption_ibfk_1` FOREIGN KEY (`voteID`) REFERENCES `tb_vote` (`voteID`); 76 77 78 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 79 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
3.运行效果
4.
5.