-
Notifications
You must be signed in to change notification settings - Fork 0
/
sgm.sql
94 lines (82 loc) · 2.89 KB
/
sgm.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
/*
Navicat MySQL Data Transfer
Source Server : localhost_3306
Source Server Version : 50717
Source Host : localhost:3306
Source Database : sgm
Target Server Type : MYSQL
Target Server Version : 50717
File Encoding : 65001
Date: 2018-06-17 22:49:15
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for course
-- ----------------------------
DROP TABLE IF EXISTS `course`;
CREATE TABLE `course` (
`cid` int(11) NOT NULL,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`cid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of course
-- ----------------------------
INSERT INTO `course` VALUES ('1', 'database');
INSERT INTO `course` VALUES ('2', 'J2EE');
INSERT INTO `course` VALUES ('3', 'web security');
-- ----------------------------
-- Table structure for grade
-- ----------------------------
DROP TABLE IF EXISTS `grade`;
CREATE TABLE `grade` (
`sid` int(11) NOT NULL,
`cid` int(11) NOT NULL,
`score` double(11,1) NOT NULL,
PRIMARY KEY (`sid`,`cid`),
KEY `fk2` (`cid`),
CONSTRAINT `fk1` FOREIGN KEY (`sid`) REFERENCES `student` (`sid`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk2` FOREIGN KEY (`cid`) REFERENCES `course` (`cid`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of grade
-- ----------------------------
INSERT INTO `grade` VALUES ('1', '1', '98.6');
INSERT INTO `grade` VALUES ('1', '2', '96.8');
INSERT INTO `grade` VALUES ('2', '1', '86.0');
INSERT INTO `grade` VALUES ('2', '2', '98.7');
INSERT INTO `grade` VALUES ('5', '1', '98.3');
INSERT INTO `grade` VALUES ('5', '3', '98.0');
-- ----------------------------
-- Table structure for student
-- ----------------------------
DROP TABLE IF EXISTS `student`;
CREATE TABLE `student` (
`sid` int(11) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`sex` varchar(255) DEFAULT NULL,
PRIMARY KEY (`sid`),
KEY `sid` (`sid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of student
-- ----------------------------
INSERT INTO `student` VALUES ('1', 'Ender', 'male');
INSERT INTO `student` VALUES ('2', 'Peter', 'male');
INSERT INTO `student` VALUES ('3', 'Valentine', 'female');
INSERT INTO `student` VALUES ('4', 'Kid', 'male');
INSERT INTO `student` VALUES ('5', 'Alice', 'female');
-- ----------------------------
-- Table structure for teacher
-- ----------------------------
DROP TABLE IF EXISTS `teacher`;
CREATE TABLE `teacher` (
`tid` int(11) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
PRIMARY KEY (`tid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of teacher
-- ----------------------------
INSERT INTO `teacher` VALUES ('1', 'Mazer Rackham', '20180510');