-
Notifications
You must be signed in to change notification settings - Fork 1
/
managesystem.sql
155 lines (114 loc) · 6.86 KB
/
managesystem.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
SQLyog Ultimate v12.08 (64 bit)
MySQL - 8.0.15 : Database - examination_system
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`examination_system` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */;
USE `examination_system`;
/*Table structure for table `college` */
DROP TABLE IF EXISTS `college`;
CREATE TABLE `college` (
`collegeID` int(11) NOT NULL,
`collegeName` varchar(200) NOT NULL COMMENT '课程名',
PRIMARY KEY (`collegeID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*Data for the table `college` */
insert into `college`(`collegeID`,`collegeName`) values (1,'计算机系'),(2,'设计系'),(3,'财经系'),(4,'经济管理系'),(5,'文学系');
/*Table structure for table `course` */
DROP TABLE IF EXISTS `course`;
CREATE TABLE `course` (
`courseID` int(11) NOT NULL,
`courseName` varchar(200) NOT NULL COMMENT '课程名称',
`teacherID` int(11) NOT NULL,
`courseTime` varchar(200) DEFAULT NULL COMMENT '开课时间',
`classRoom` varchar(200) DEFAULT NULL COMMENT '开课地点',
`courseWeek` int(200) DEFAULT NULL COMMENT '学时',
`courseType` varchar(20) DEFAULT NULL COMMENT '课程类型',
`collegeID` int(11) NOT NULL COMMENT '所属院系',
`score` int(11) NOT NULL COMMENT '学分',
PRIMARY KEY (`courseID`),
KEY `collegeID` (`collegeID`),
KEY `teacherID` (`teacherID`),
CONSTRAINT `course_ibfk_1` FOREIGN KEY (`collegeID`) REFERENCES `college` (`collegeID`),
CONSTRAINT `course_ibfk_2` FOREIGN KEY (`teacherID`) REFERENCES `teacher` (`userID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*Data for the table `course` */
insert into `course`(`courseID`,`courseName`,`teacherID`,`courseTime`,`classRoom`,`courseWeek`,`courseType`,`collegeID`,`score`) values (1,'C语言程序设计',1001,'周二','科401',18,'必修课',1,3),(2,'Python爬虫技巧',1001,'周四','X402',18,'必修课',1,3),(3,'数据结构',1001,'周四','科401',18,'必修课',1,2),(4,'Java程序设计',1002,'周五','科401',18,'必修课',1,2),(5,'英语',1001,'周四','X302',18,'必修课',1,2),(6,'服装设计',1003,'周一','科401',18,'选修课',2,2),(7,'FinanceManagement',1000,'周日','A101',18,'必修课',3,5);
/*Table structure for table `role` */
DROP TABLE IF EXISTS `role`;
CREATE TABLE `role` (
`roleID` int(11) NOT NULL,
`roleName` varchar(20) NOT NULL,
`permissions` varchar(255) DEFAULT NULL COMMENT '权限',
PRIMARY KEY (`roleID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*Data for the table `role` */
insert into `role`(`roleID`,`roleName`,`permissions`) values (0,'admin',NULL),(1,'teacher',NULL),(2,'student',NULL);
/*Table structure for table `selectedcourse` */
DROP TABLE IF EXISTS `selectedcourse`;
CREATE TABLE `selectedcourse` (
`courseID` int(11) NOT NULL,
`studentID` int(11) NOT NULL,
`mark` int(11) DEFAULT NULL COMMENT '成绩',
KEY `courseID` (`courseID`),
KEY `studentID` (`studentID`),
CONSTRAINT `selectedcourse_ibfk_1` FOREIGN KEY (`courseID`) REFERENCES `course` (`courseID`),
CONSTRAINT `selectedcourse_ibfk_2` FOREIGN KEY (`studentID`) REFERENCES `student` (`userID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*Data for the table `selectedcourse` */
insert into `selectedcourse`(`courseID`,`studentID`,`mark`) values (2,10001,12),(1,10001,95),(1,10002,66),(1,10003,80),(2,10003,99),(3,10001,81),(4,10001,NULL),(7,10001,NULL);
/*Table structure for table `student` */
DROP TABLE IF EXISTS `student`;
CREATE TABLE `student` (
`userID` int(11) NOT NULL AUTO_INCREMENT,
`userName` varchar(200) NOT NULL,
`sex` varchar(20) DEFAULT NULL,
`birthYear` date DEFAULT NULL COMMENT '出生日期',
`grade` date DEFAULT NULL COMMENT '入学时间',
`collegeID` int(11) NOT NULL COMMENT '院系id',
PRIMARY KEY (`userID`),
KEY `collegeID` (`collegeID`),
CONSTRAINT `student_ibfk_1` FOREIGN KEY (`collegeID`) REFERENCES `college` (`collegeID`)
) ENGINE=InnoDB AUTO_INCREMENT=11113 DEFAULT CHARSET=utf8;
/*Data for the table `student` */
insert into `student`(`userID`,`userName`,`sex`,`birthYear`,`grade`,`collegeID`) values (10001,'小黄','男','1996-09-02','2015-09-02',1),(10002,'小米','女','1995-09-14','2015-09-02',3),(10003,'小陈','女','1996-09-02','2015-09-02',2),(10004,'小华','男','1996-09-02','2015-09-02',5),(10005,'小左','男','1996-09-02','2015-09-02',4),(10006,'小拉','女','1996-09-02','2015-09-02',1);
/*Table structure for table `teacher` */
DROP TABLE IF EXISTS `teacher`;
CREATE TABLE `teacher` (
`userID` int(11) NOT NULL AUTO_INCREMENT,
`userName` varchar(200) NOT NULL,
`sex` varchar(20) DEFAULT NULL,
`birthYear` date NOT NULL,
`degree` varchar(20) DEFAULT NULL COMMENT '学历',
`title` varchar(255) DEFAULT NULL COMMENT '职称',
`grade` date DEFAULT NULL COMMENT '入职时间',
`collegeID` int(11) NOT NULL COMMENT '院系',
PRIMARY KEY (`userID`),
KEY `collegeID` (`collegeID`),
CONSTRAINT `teacher_ibfk_1` FOREIGN KEY (`collegeID`) REFERENCES `college` (`collegeID`)
) ENGINE=InnoDB AUTO_INCREMENT=1004 DEFAULT CHARSET=utf8;
/*Data for the table `teacher` */
insert into `teacher`(`userID`,`userName`,`sex`,`birthYear`,`degree`,`title`,`grade`,`collegeID`) values (1000,'陈纲','男','1995-07-31','本科','教授','2018-11-01',3),(1001,'刘老师','女','1990-03-08','硕士','副教授','2015-09-02',2),(1002,'张老师','男','1996-09-02','本科','普通教师','2015-09-02',4),(1003,'贾老师','女','1996-09-02','硕士','助教','2017-07-07',1);
/*Table structure for table `userlogin` */
DROP TABLE IF EXISTS `userlogin`;
CREATE TABLE `userlogin` (
`userID` int(11) NOT NULL AUTO_INCREMENT,
`userName` varchar(200) NOT NULL,
`password` varchar(200) NOT NULL,
`role` int(11) NOT NULL DEFAULT '2' COMMENT '角色权限',
PRIMARY KEY (`userID`),
KEY `role` (`role`),
CONSTRAINT `userlogin_ibfk_1` FOREIGN KEY (`role`) REFERENCES `role` (`roleID`)
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8;
/*Data for the table `userlogin` */
insert into `userlogin`(`userID`,`userName`,`password`,`role`) values (1,'admin','123',0),(8,'10001','123',2),(9,'10002','123',2),(10,'10003','123',2),(11,'10005','123',2),(12,'10004','123',2),(13,'10006','123',2),(14,'1001','123',1),(15,'1002','123',1),(16,'1003','123',1),(19,'1000','123',1);
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;