-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate-tables.sql
More file actions
78 lines (67 loc) · 2.05 KB
/
create-tables.sql
File metadata and controls
78 lines (67 loc) · 2.05 KB
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
create database courseeval;
use courseeval;
create table instructor (
instructorid varchar(20) not null,
fname varchar(50),
lname varchar(50),
constraint instructorPK primary key(instructorid)
);
create table class (
class_num int not null,
course_name varchar(250),
section_num int,
semester varchar(20),
year varchar(20),
constraint classPK primary key(class_num)
);
create table teaches (
instructorid varchar(20) not null,
class_num int not null,
constraint teachesFK1 foreign key(instructorid) references instructor(instructorid),
constraint teachesFK2 foreign key(class_num) references class(class_num)
);
create table student (
studentid varchar(50) not null,
constraint studentPK primary key(studentid)
);
create table takes (
studentid varchar(50) not null,
class_num int not null,
constraint takesFK1 foreign key(studentid) references student(studentid),
constraint takesFK2 foreign key(class_num) references class(class_num)
);
create table evaluation(
evalid int not null,
studentid varchar(50) not null,
class_num int not null,
constraint evalPK primary key (evalid),
constraint evalFK1 foreign key(studentid) references student(studentid),
constraint evalFK2 foreign key(class_num) references class(class_num),
unique(evalid)
);
create table question(
questionid int not null,
type varchar(20),
text varchar(255),
options varchar (500),
constraint questionFK primary key(questionid)
);
create table class_question(
class_num int not null,
questionid int not null,
constraint class_questionFK1 foreign key(class_num) references class(class_num),
constraint class_questionFK2 foreign key(questionid) references question(questionid)
);
create table answer (
answerid int not null,
response varchar(500),
questionid int not null,
constraint answerPK primary key(answerid),
constraint answerFK foreign key(questionid) references question(questionid)
);
create table eval_answer (
evalid int not null,
answerid int not null,
constraint eval_answerFK1 foreign key(evalid) references evaluation(evalid),
constraint eval_answerFK2 foreign key(answerid) references answer(answerid)
);