-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProject.sql
186 lines (166 loc) · 3.88 KB
/
Project.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
create database GUCera;
create table Users
(
id int identity,
firstName varchar(20),
lastName varchar(20),
password varchar(20),
gender bit,
email varchar(50),
address varchar(10),
PRIMARY key (id)
)
create table Instructor
(
id int,
rating decimal(2, 1),
FOREIGN Key (id) references Users,
PRIMARY KEY (id)
)
create table UserMobileNumber
(
id int,
mobileNumber varchar(20),
FOREIGN key (id) references Users,
PRIMARY key (id, mobileNumber)
)
create table Student
(
id int,
gpa real,
Primary key (id),
foreign key (id) references Users
)
create table Admin
(
id int,
primary key (id),
foreign key (id) references Users
)
create table Course
(
id int identity,
creditHours int,
name varchar(20),
courseDescription varchar(200),
price real,
content varchar(200),
adminId int,
instructorId int,
accepted bit,
primary key (id),
foreign key (adminId) references Admin,
foreign key (instructorId) references Instructor
)
create table Assignment
(
cid int,
number int,
type varchar(10),
fullGrade int,
weight decimal(4, 1),
deadline datetime,
content varchar(200),
PRIMARY KEY (cid, number, type),
foreign key (cid) references Course
)
Create TABLE StudentTakeAssignment
(
sid int,
cid int,
assignmentNumber int,
assignmentType varchar(10),
grade decimal(5, 2),
PRIMARY KEY (sid, cid, assignmentNumber, assignmentType, grade),
FOREIGN Key (sid) references Student,
FOREIGN Key (cid, assignmentNumber, assignmentType) references ASSIGNMENT,
)
CREATE TABLE StudentRateInstructor
(
sid int,
instId int,
rate int,
PRIMARY KEY (sid, instId)
)
CREATE TABLE StudentCertifyCourse
(
sid int,
cid int,
issueDate DATETIME,
FOREIGN KEY (sid) REFERENCES Student,
foreign key (cid) REFERENCES Course,
PRIMARY KEY (sid, cid)
)
CREATE TABLE CoursePrerequisiteCourse
(
cid int,
prerequisiteId int,
FOREIGN KEY (cid) REFERENCES Course,
FOREIGN KEY (prerequisiteId) REFERENCES Course,
primary KEY (cid, prerequisiteId)
)
CREATE TABLE InstructorTeachCourse
(
instId int,
cid int,
FOREIGN KEY (instId) REFERENCES Instructor,
FOREIGN KEY (cid) REFERENCES Course,
PRIMARY KEY (instId, cid)
)
create table Feedback
(
cid int,
number int,
comments varchar(100),
numberOfLikes int,
sid int,
primary key (cid, number),
foreign key (cid) references Course,
foreign key (sid) references Student
)
create table Promocode
(
code varchar(6),
issueDate datetime,
expiryDate datetime,
discountamount decimal(10, 2),
adminId int,
primary key (code),
foreign key (adminId) references Admin
)
create table StudentHasPromocode
(
sid int,
code varchar(6),
primary key (sid, code),
foreign key (sid) references Student,
foreign key (code) references Promocode
)
create table CreditCard
(
number int,
cardHolderName varchar(16),
expiryDate datetime,
cvv varchar(3),
primary key (number),
)
create table StudentAddCreditCard
(
sid int,
creditCardNumber int,
primary key (sid, creditCardNumber),
foreign key (sid) references Student,
foreign key (creditCardNumber) references CreditCard
)
create table StudentTakeCourse
(
sid int,
cid int,
instId int,
payedfor bit,
grade decimal(10, 2),
primary key (sid, cid, instId),
foreign key (sid) references Student,
foreign key (cid) references Course,
foreign key (instId) references Instructor
)