-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.sql
258 lines (225 loc) · 10.1 KB
/
db.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
-- MySQL dump 10.13 Distrib 5.6.50, for Linux (x86_64)
--
-- Host: localhost Database: ssm
-- ------------------------------------------------------
-- Server version 5.6.50-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!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 */;
--
-- Table structure for table `classes`
--
DROP TABLE IF EXISTS `classes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `classes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`major` varchar(50) NOT NULL,
`num` int(11) NOT NULL,
`year` int(11) NOT NULL,
`counsellor` varchar(50) NOT NULL COMMENT '辅导员名称',
`class_id` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `classes_class_id_uindex` (`class_id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `classes`
--
LOCK TABLES `classes` WRITE;
/*!40000 ALTER TABLE `classes` DISABLE KEYS */;
INSERT INTO `classes` VALUES (1,'1901A','计算机科学与技术',30,2022,'张老师','1901'),(5,'1902A','软件工程',60,2018,'王宇哲','1902'),(6,'1903A','网络安全',60,2018,'王宇哲','1903');
/*!40000 ALTER TABLE `classes` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `course`
--
DROP TABLE IF EXISTS `course`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `course` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`course_id` varchar(20) NOT NULL,
`name` varchar(50) NOT NULL,
`hours` int(11) NOT NULL,
`credit` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `course_course_id_uindex` (`course_id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `course`
--
LOCK TABLES `course` WRITE;
/*!40000 ALTER TABLE `course` DISABLE KEYS */;
INSERT INTO `course` VALUES (1,'1001','高等数学',64,4),(2,'1002','离散数学',48,3),(6,'1004','测试课程2',32,2),(7,'0001','你好',11,11),(12,'10012','1111',1111,1111);
/*!40000 ALTER TABLE `course` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `course_schedule`
--
DROP TABLE IF EXISTS `course_schedule`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `course_schedule` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`course_id` varchar(20) NOT NULL,
`class_id` varchar(20) NOT NULL,
`teacher_id` varchar(20) NOT NULL,
`start_time` int(11) NOT NULL COMMENT '上课节次的起始',
`end_time` int(11) NOT NULL COMMENT '上课节次的结束',
`location` varchar(100) DEFAULT NULL,
`week` int(11) NOT NULL COMMENT '教学周数',
`day` int(11) NOT NULL COMMENT '星期几',
PRIMARY KEY (`id`),
UNIQUE KEY `index2` (`course_id`,`teacher_id`,`class_id`,`end_time`,`start_time`,`location`,`day`),
KEY `course_schedule_classes_class_id_fk` (`class_id`),
KEY `course_schedule_teacher_teacher_id_fk` (`teacher_id`),
CONSTRAINT `course_schedule_classes_class_id_fk` FOREIGN KEY (`class_id`) REFERENCES `classes` (`class_id`) ON DELETE CASCADE,
CONSTRAINT `course_schedule_course_course_id_fk` FOREIGN KEY (`course_id`) REFERENCES `course` (`course_id`) ON DELETE CASCADE,
CONSTRAINT `course_schedule_teacher_teacher_id_fk` FOREIGN KEY (`teacher_id`) REFERENCES `teacher` (`teacher_id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `course_schedule`
--
LOCK TABLES `course_schedule` WRITE;
/*!40000 ALTER TABLE `course_schedule` DISABLE KEYS */;
INSERT INTO `course_schedule` VALUES (1,'1001','1901','t001',1,2,'教学楼',2,23),(2,'1002','1901','t002',3,4,'教室2',32769,5),(13,'1002','1901','t002',7,9,'三元区',32769,7),(40,'1001','1901','t001',1,4,'教一',32768,8),(41,'1001','1901','t001',1,3,'教一',32768,16),(42,'1001','1901','t001',1,3,'教一',16384,8),(43,'0001','1901','t003',1,5,'三元区',256,4);
/*!40000 ALTER TABLE `course_schedule` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `grade`
--
DROP TABLE IF EXISTS `grade`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `grade` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`student_id` varchar(20) NOT NULL,
`course_id` varchar(20) NOT NULL,
`score` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `grade_course_id_student_id_uindex` (`course_id`,`student_id`),
KEY `grade_student_student_id_fk` (`student_id`),
CONSTRAINT `grade_course_course_id_fk` FOREIGN KEY (`course_id`) REFERENCES `course` (`course_id`) ON DELETE CASCADE,
CONSTRAINT `grade_student_student_id_fk` FOREIGN KEY (`student_id`) REFERENCES `student` (`student_id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=99 DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `grade`
--
LOCK TABLES `grade` WRITE;
/*!40000 ALTER TABLE `grade` DISABLE KEYS */;
INSERT INTO `grade` VALUES (3,'101','1002',-1),(8,'101','1001',811),(9,'102','1001',22),(33,'102','1002',51),(92,'103','1002',92),(93,'103','1001',95);
/*!40000 ALTER TABLE `grade` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `student`
--
DROP TABLE IF EXISTS `student`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`student_id` varchar(20) NOT NULL,
`name` varchar(50) NOT NULL,
`gender` varchar(10) NOT NULL DEFAULT '男',
`birthday` date DEFAULT NULL,
`major` varchar(50) DEFAULT NULL,
`class_id` varchar(50) NOT NULL,
`address` varchar(100) DEFAULT NULL,
`phone` varchar(20) DEFAULT NULL,
`note` varchar(200) DEFAULT NULL,
`user_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `student_student_id_uindex` (`student_id`),
KEY `student_classes_class_id_fk` (`class_id`),
KEY `student_ibfk_1` (`user_id`),
CONSTRAINT `student_classes_class_id_fk` FOREIGN KEY (`class_id`) REFERENCES `classes` (`class_id`),
CONSTRAINT `student_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `student`
--
LOCK TABLES `student` WRITE;
/*!40000 ALTER TABLE `student` DISABLE KEYS */;
INSERT INTO `student` VALUES (1,'101','王老六','男','1999-01-01','计算机科学与技术','1901','江苏苏州','139123456','备注',4),(2,'102','李四','女','2000-02-02','软件工程','1901','江苏南京','139111111','备注2',5),(3,'103','小安','女','2001-03-03','软件工程','1901','湖北孝感','19522223333','备注3',6);
/*!40000 ALTER TABLE `student` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `teacher`
--
DROP TABLE IF EXISTS `teacher`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `teacher` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`teacher_id` varchar(20) NOT NULL,
`name` varchar(50) NOT NULL,
`gender` varchar(10) NOT NULL DEFAULT '男',
`birthday` date DEFAULT NULL,
`faculty` varchar(50) DEFAULT NULL,
`phone` varchar(20) DEFAULT NULL,
`user_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `teacher_teacher_id_uindex` (`teacher_id`),
KEY `teacher_ibfk_1` (`user_id`),
CONSTRAINT `teacher_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `teacher`
--
LOCK TABLES `teacher` WRITE;
/*!40000 ALTER TABLE `teacher` DISABLE KEYS */;
INSERT INTO `teacher` VALUES (1,'t001','王宇哲','男','1980-01-01','计算机科学与技术系','13333334444',3),(3,'t003','郭老师','男','1970-01-01','物联网',NULL,2),(4,'t002','赵老师','男','1970-01-01','软件工程','15171285137',2);
/*!40000 ALTER TABLE `teacher` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`password` varchar(50) NOT NULL,
`user_type` varchar(10) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `users`
--
LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
INSERT INTO `users` VALUES (2,'teacher1','teacher1','teacher'),(3,'teacher2','teacher2','teacher'),(4,'student1','123456','student'),(5,'student2','student2','student'),(6,'qqq','q111','admin'),(8,'admin','admin','admin'),(17,'xiaowang','123456','admin'),(24,'admin1','123456','admin');
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Dumping events for database 'ssm'
--
--
-- Dumping routines for database 'ssm'
--
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2023-05-30 12:00:14