从本篇开始,速度会变快一点,然后注释会精简一点,但是代码会贴的全一点。
本篇来实现jsp+Servlet培训班作业管理系统的数据库部分。
首先通过Navicat的ER图标来阅览整个结构:
具体说明如下:
system_role 系统角色表-role_id 角色编号-role_name 角色名称(校长、教师、学生三选一)system_user 系统用户表-user_id 用户编号-user_role 用户角色(外键)-user_name 用户名称-user_passWord 用户密码system_course 系统课程表-course_id 课程编号-course_user 课程创建者(外键)-course_name 课程名称system_work 系统作业表-work_id 作业编号-work_title 作业标题-work_course 作业所属课程(外键)-work_time 作业发布时间student_job 学生作业表-job_id 作业编号-job_work 所属系统作业(外键,指向work_id)-job_user 提交作业的学生(外键)-job_time 作业提交时间-job_content 作业内容-job_score 得分(0优秀 1良好 2合格 3不合格)接下来具体的sql代码,需要注意库中已有3个角色,同时具有1个张三校长,其密码1234,测试期间所有密码均使用1234
/*Navicat MySQL Data TransferSource Server : 本机数据库Source Server Version : 50552Source Host : 127.0.0.1:3306Source Database : homeworkTarget Server Type : MYSQLTarget Server Version : 50552File Encoding : 65001Date: 2017-02-04 16:44:00*/SET FOREIGN_KEY_CHECKS=0;-- ------------------------------ Table structure for `student_job`-- ----------------------------DROP TABLE IF EXISTS `student_job`;CREATE TABLE `student_job` ( `job_id` int(10) NOT NULL AUTO_INCREMENT, `job_work` int(10) DEFAULT NULL, `job_user` int(10) DEFAULT NULL, `job_time` datetime DEFAULT NULL, `job_content` varchar(2000) DEFAULT NULL, `job_score` varchar(1) DEFAULT '' COMMENT '0优秀 1良好 2合格 3不合格', PRIMARY KEY (`job_id`), KEY `fk_job_user` (`job_user`), KEY `fk_job_work` (`job_work`), CONSTRAINT `fk_job_user` FOREIGN KEY (`job_user`) REFERENCES `system_user` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_job_work` FOREIGN KEY (`job_work`) REFERENCES `system_work` (`work_id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=utf8;-- ------------------------------ Records of student_job-- ------------------------------ ------------------------------ Table structure for `system_course`-- ----------------------------DROP TABLE IF EXISTS `system_course`;CREATE TABLE `system_course` ( `course_id` int(10) NOT NULL AUTO_INCREMENT, `course_user` int(10) DEFAULT NULL, `course_name` varchar(20) DEFAULT NULL, PRIMARY KEY (`course_id`), KEY `fk_course_user` (`course_user`), CONSTRAINT `fk_course_user` FOREIGN KEY (`course_user`) REFERENCES `system_user` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=utf8;-- ------------------------------ Records of system_course-- ------------------------------ ------------------------------ Table structure for `system_role`-- ----------------------------DROP TABLE IF EXISTS `system_role`;CREATE TABLE `system_role` ( `role_id` int(10) NOT NULL AUTO_INCREMENT, `role_name` varchar(200) DEFAULT NULL, PRIMARY KEY (`role_id`)) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;-- ------------------------------ Records of system_role-- ----------------------------INSERT INTO `system_role` VALUES ('1', '校长');INSERT INTO `system_role` VALUES ('2', '教师');INSERT INTO `system_role` VALUES ('3', '学生');-- ------------------------------ Table structure for `system_user`-- ----------------------------DROP TABLE IF EXISTS `system_user`;CREATE TABLE `system_user` ( `user_id` int(10) NOT NULL AUTO_INCREMENT, `user_role` int(10) DEFAULT NULL, `user_name` varchar(20) DEFAULT NULL, `user_password` varchar(20) DEFAULT NULL, PRIMARY KEY (`user_id`), KEY `fk_user_role` (`user_role`), CONSTRAINT `fk_user_role` FOREIGN KEY (`user_role`) REFERENCES `system_role` (`role_id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;-- ------------------------------ Records of system_user-- ----------------------------INSERT INTO `system_user` VALUES ('1', '1', '张三', '1234');-- ------------------------------ Table structure for `system_work`-- ----------------------------DROP TABLE IF EXISTS `system_work`;CREATE TABLE `system_work` ( `work_id` int(10) NOT NULL AUTO_INCREMENT, `work_title` varchar(2000) DEFAULT NULL, `work_course` int(10) NOT NULL, `work_time` datetime DEFAULT NULL, PRIMARY KEY (`work_id`), KEY `fk_work_course` (`work_course`), CONSTRAINT `fk_work_course` FOREIGN KEY (`work_course`) REFERENCES `system_course` (`course_id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=utf8;-- ------------------------------ Records of system_work-- ----------------------------新闻热点
疑难解答