-
Notifications
You must be signed in to change notification settings - Fork 0
/
create.sql~
44 lines (36 loc) · 815 Bytes
/
create.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
CREATE DATABASE TWDemo;
USE TWDemo;
CREATE TABLE class(
cls_id INT NOT NULL PRIMARY KEY,
cls_name VARCHAR(20),
cls_member INT
);
CREATE TABLE student(
stu_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
stu_no CHAR(10),
stu_name VARCHAR(20),
gender VARCHAR(6),
cls_id INT,
FOREIGN KEY (cls_id) REFERENCES class(cls_id)
);
CREATE TABLE course(
c_no INT NOT NULL PRIMARY KEY ,
c_name VARCHAR(20),
c_day CHAR(4),
c_time INT ,
credit INT
);
CREATE TABLE schedule(
sch_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
stu_id INT,
FOREIGN KEY (stu_id) REFERENCES student(stu_id)
);
CREATE TABLE sele_course(
stu_id INT,
sch_id INT,
c_no INT,
FOREIGN KEY (stu_id) REFERENCES student(stu_id),
FOREIGN KEY (c_no) REFERENCES course(c_no),
FOREIGN KEY (sch_id) REFERENCES schedule(sch_id),
PRIMARY KEY (stu_id,c_no,sch_id)
);