-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.sql
305 lines (269 loc) · 7.05 KB
/
schema.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
drop table if exists person;
create table person(
email varchar(50) not null,
fname varchar(50) not null,
mname varchar(25),
lname varchar(25) not null,
birthdate date not null,
password varchar(100) not null,
constraint person_email_pk Primary Key(email)
);
drop table if exists student;
create table student(
studentno character(10) not null,
degree varchar(70) not null,
college varchar(55) not null,
constraint student_email_pk Primary Key(email)
)inherits(person);
/*INSERT STUDENT*/
insert into student values(
'Joshze Rica',
'Luklukan',
'Esguerra',
to_date('08-05-1997', 'MM-DD-YYYY'),
'fGhdjs86h0fjnoPie32',
'2013-30624',
'BS Computer Science',
'College of Arts and Sciences'
);
insert into student values(
'Jose Protacio',
'Rizal Mercado',
'y Realonda',
to_date('07-19-2010', 'MM-DD-YYYY'),
'dfHduitro08df083dg9',
'2011-30624',
'BS Nutrition',
'College of Human Ecology'
);
insert into student values(
'Juan',
'Dela',
'Cruz',
to_date('12-25-1992', 'MM-DD-YYYY'),
'sdiEuif064hf9as094',
'2009-56905',
'BS Chemical Engineering',
'College of Engineering and Agro-Industrial Technology'
);
drop table if exists teacher;
create table Teacher (
employeeno char (10) not null,
constraint Teacher_email_pk Primary Key(email)
)inherits(person);
insert into Teacher values(
'Reginald Neil',
'C',
'Recario',
to_date('01-01-1994','DD-MM-YYYY'),
'password',
'0001112221'
);
insert into Teacher values(
'Lailanie',
'R',
'Danila',
to_date('02-02-1994','DD-MM-YYYY'),
'password2',
'1112223698'
);
insert into Teacher values(
'Caroline Natalie',
'M',
'Peralta',
to_date('03-03-1994','DD-MM-YYYY'),
'password3',
'1234567890'
);
drop table if exists Teacher_Degree_List;
create table Teacher_Degree_List (
teacher_email varchar(50) not null,
degree varchar(70) not null,
constraint Teacher_Degree_List_pk Primary Key(teacher_email, degree),
constraint Teacher_Degree_List_teacher_email_fk Foreign Key(teacher_email) References Teacher(email)
);
insert into Teacher_Degree_List values(
'[email protected]','BS Computer Science'
);
insert into Teacher_Degree_List values(
'[email protected]','BS Computer Science'
);
insert into Teacher_Degree_List values(
'[email protected]','BS Computer Science'
);
/*CREATE*/
drop table if exists class;
create table class(
portal varchar(10) not null,
coursecode varchar(10) not null,
coursename varchar(100) not null,
section varchar(5) not null,
description text,
teacheremail varchar(50) not null,
constraint class_portal_pk Primary Key(portal),
constraint class_teacheremail_fk Foreign Key(teacheremail) References teacher(email)
);
insert into class values(
'abcdefghij',
'SEXED 101',
'A journey into sex',
'C-10L',
'This course will teach about the different sex practices of different cultures',
);
insert into class values(
'zxcvbnmtre',
'SEXED 101',
'A journey into sex',
'C-19L',
'This course will teach about the different sex practices of different cultures',
);
insert into class values(
'asdfghjklp',
'FASH 1',
'Introduction into the study of the expression beauty in clothing',
'A-2L',
'Delve into the intricacies of fashion design, discuss what is beauty, and learn how to discern true beauty from normal beauty',
);
drop table if exists class_list;
create table class_list(
portal varchar(10) not null,
studentemail varchar(50) not null,
isenrolled boolean default false,
constraint student_pk Primary Key(portal, studentemail),
constraint class_list_portal_fk Foreign Key(portal) References class(portal),
constraint class_studentemail_fk Foreign Key(studentemail) References student(email)
);
insert into class_list values(
'asdfghjklp',
);
insert into class_list values(
'asdfghjklp',
);
insert into class_list values(
'zxcvbnmtre',
);
insert into class_list values(
'abcdefghij',
);
drop table if exists requirement cascade;
create table requirement (
id varchar(10) not null,
description text,
name varchar(50) not null,
type varchar(20) not null,
duedate timestamp not null,
maxgrade numeric(3) not null,
classportal varchar(10) not null,
teacheremail varchar(50) not null,
constraint requirement_requirementid_pk Primary Key(id, classportal),
constraint requirement_classportal_fk Foreign Key(classportal) References class(portal),
constraint requirement_teacheremail_fk Foreign Key(teacheremail) References teacher(email)
);
drop table if exists requirement_passed;
create table requirement_passed (
requirementid varchar(10) not null,
classportal varchar(10) not null,
studentemail varchar(50) not null,
grade numeric(3) not null,
submissiondate timestamp not null,
constraint requirement_Passed_pk Primary Key(requirementid, classportal, studentemail),
constraint requirement_Passed_Requirementid_fk Foreign Key(requirementid, classportal) References Requirement(id, classportal),
constraint requirement_passed_studentemai_fk Foreign Key(studentemail) References student(email)
);
insert into Requirement(id, description, name, type, duedate, maxgrade, classportal, teacheremail)
values(
'1',
'Eessay on the history of fashion',
'Essay 1',
'Essay',
current_timestamp,
100,
'abcdefghij',
);
insert into Requirement(id, description, name, type, duedate, maxgrade, classportal, teacheremail)
values(
'2',
'Exercise on fashion design',
'Exer 12',
'Exercise',
current_timestamp,
100,
'asdfghjklp',
);
insert into Requirement(id, description, name, type, duedate, maxgrade, classportal, teacheremail)
values(
'1',
'',
'',
'Essay',
current_timestamp,
20,
'asdfghjklp',
);
insert into Requirement_Passed
values(
'1',
'abcdefghij',
12,
current_timestamp
);
insert into Requirement_Passed
values(
'2',
'asdfghjklp',
12,
current_timestamp
);
insert into Requirement_Passed
values(
'1',
'asdfghjklp',
14,
current_timestamp
);
drop table if exists fileupload;
create table fileupload(
fileno serial not null,
filename varchar(25) not null,
filedescription text,
classportal varchar(10) not null,
constraint fileupload_fileno_pk Primary Key(fileno),
constraint fileupload_classportal_fk Foreign Key(classportal) References class(portal)
);
insert into fileupload(filename, filedescription, classportal)
values(
'SEXED 101 Handout1.pdf',
'1st Handout for SEXED 101 Laborotary 1S1516',
'abcdefghij'
);
insert into fileupload(filename, filedescription, classportal)
values(
'FASH 1 Handout1.pdf',
'1st Handout for FASH 1 Laborotary 1S1516',
'asdfghjklp'
);
insert into fileupload(filename, filedescription, classportal)
values(
'FASH 1 Handout2.pdf',
'2nd Handout for FASH 1 Laborotary 1S1516',
'asdfghjklp'
);