forked from seming/dbproject_courseregistration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_table.txt
57 lines (53 loc) · 1.4 KB
/
create_table.txt
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
CREATE TABLE STUDENT
( s_id VARCHAR(20) not null,
s_pwd VARCHAR(20) not null,
s_name VARCHAR(20) not null,
s_grade NUMBER not null,
s_major VARCHAR(50) not null,
CONSTRAINT student_pk PRIMARY KEY (s_id)
);
CREATE TABLE course(
c_id VARCHAR(20),
c_name VARCHAR(100),
c_id_no NUMBER,
c_time_start VARCHAR(20),
c_time_end VARCHAR(20),
c_day NUMBER,
c_unit NUMBER,
c_max NUMBER,
c_where VARCHAR(50),
CONSTRAINT c_pk PRIMARY KEY (c_id, c_id_no)
);
CREATE TABLE enroll(
s_id VARCHAR(20),
c_id VARCHAR(20),
c_id_no NUMBER,
e_year NUMBER,
e_semester NUMBER,
CONSTRAINT e_pk PRIMARY KEY (s_id, c_id, c_id_no) ,
CONSTRAINT e_s_fk FOREIGN KEY(s_id)
REFERENCES student (s_id),
CONSTRAINT e_c_fk FOREIGN KEY (c_id, c_id_no)
REFERENCES course (c_id, c_id_no)
);
CREATE TABLE teach
(
p_id VARCHAR(20),
c_id VARCHAR(20),
c_id_no NUMBER,
t_year NUMBER,
t_semester NUMBER,
CONSTRAINT t_pk PRIMARY KEY (p_id, c_id, c_id_no, t_year, t_semester),
CONSTRAINT t_p_fk FOREIGN KEY (p_id)
REFERENCES professor (p_id),
CONSTRAINT t_c_fk FOREIGN KEY (c_id, c_id_no)
REFERENCES course (c_id, c_id_no)
);
CREATE TABLE professor
(
p_id VARCHAR(20) not null,
p_pwd VARCHAR(20) not null,
p_name VARCHAR(20) not null,
p_major VARCHAR(50) not null,
CONSTRAINT p_pk PRIMARY KEY (p_id)
);