-
Notifications
You must be signed in to change notification settings - Fork 0
/
SCHEMA.sql
228 lines (165 loc) · 8.45 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
CREATE TABLE STUDENT_DBR
(
STUDENT_ID int NOT NULL,
FIRST_NAME VARCHAR(20) NOT NULL,
LAST_NAME VARCHAR(20) NOT NULL,
MAIL VARCHAR(30) NOT NULL,
AGE INT NOT NULL,
JOIN_DATE DATE NOT NULL,
STUDY_YEAR INT NOT NULL,
PRIMARY KEY(STUDENT_ID)
);
CREATE TABLE PROF_DBR
(
PROF_ID int NOT NULL,
FIRST_NAME VARCHAR(20) NOT NULL,
LAST_NAME VARCHAR(20) NOT NULL,
MAIL VARCHAR(30) NOT NULL,
AGE INT NOT NULL,
JOIN_DATE DATE NOT NULL,
TEACH VARCHAR(30) NOT NULL,
PRIMARY KEY(PROF_ID)
);
CREATE TABLE REGISTER_DBR
(
REGISTER_ID INT NOT NULL,
STUDENT_ID INT NOT NULL,
GRADE_1 INT,
GRADE_2 INT,
GRADE_3 INT,
CLASS_NAME_1 VARCHAR(30),
CLASS_NAME_2 VARCHAR(30),
CLASS_NAME_3 VARCHAR(30),
PRIMARY KEY(REGISTER_ID),
FOREIGN KEY(STUDENT_ID) REFERENCES STUDENT_DBR(STUDENT_ID)
);
CREATE TABLE CLASSROOMS_DBR
(
CLASSROOM_ID INT,
FLOOR INT,
SEATS INT,
PRIMARY KEY(CLASSROOM_ID)
);
CREATE TABLE CLASSES_DBR
(
CLASS_ID INT NOT NULL,
CLASS_NAME VARCHAR(30),
PROF_ID INT NOT NULL,
DAY_OF_WEEK INT CHECK (DAY_OF_WEEK BETWEEN 1 AND 7),
START_TIME VARCHAR(10) CHECK (START_TIME LIKE '__:__'),
CLASSROOM INT,
PRIMARY KEY(CLASS_ID),
FOREIGN KEY(CLASSROOM) REFERENCES CLASSROOMS_DBR(CLASSROOM_ID),
FOREIGN KEY(PROF_ID) REFERENCES PROF_DBR(PROF_ID)
);
--STUDENTS
INSERT INTO STUDENT_DBR(student_id,first_name,last_name,mail,age,join_date,study_year) VALUES
(1,'Bratu','Dragos','[email protected]',20,TO_DATE('13-NOV-15','DD-MON-YY'),2);
INSERT INTO STUDENT_DBR(student_id,first_name,last_name,mail,age,join_date,study_year) VALUES
(2,'Mocanu','Andrei','[email protected]',18,TO_DATE('13-NOV-16','DD-MON-YY'),1);
INSERT INTO STUDENT_DBR(student_id,first_name,last_name,mail,age,join_date,study_year) VALUES
(3,'Popescu','Radu','[email protected]',19,TO_DATE('20-DEC-20','DD-MON-YY'),2);
INSERT INTO STUDENT_DBR(student_id,first_name,last_name,mail,age,join_date,study_year) VALUES
(4,'Hughin','Melesc','[email protected]',25,TO_DATE('10-JAN-17','DD-MON-YY'),4);
INSERT INTO STUDENT_DBR(student_id,first_name,last_name,mail,age,join_date,study_year) VALUES
(5,'Ardelean','Andreea','[email protected]',22,TO_DATE('17-MAR-19','DD-MON-YY'),3);
INSERT INTO STUDENT_DBR(student_id,first_name,last_name,mail,age,join_date,study_year) VALUES
(6,'Nemtescu','Florin','[email protected]',26,TO_DATE('06-JUL-13','DD-MON-YY'),5);
INSERT INTO STUDENT_DBR(student_id,first_name,last_name,mail,age,join_date,study_year) VALUES
(7,'Boza','Horia','[email protected]',19,TO_DATE('11-JUL-15','DD-MON-YY'),4);
INSERT INTO STUDENT_DBR(student_id,first_name,last_name,mail,age,join_date,study_year) VALUES
(8,'Urduza','Mihai','[email protected]',23,TO_DATE('09-DEC-18','DD-MON-YY'),3);
INSERT INTO STUDENT_DBR(student_id,first_name,last_name,mail,age,join_date,study_year) VALUES
(9,'Ceptan','Raul','[email protected]',25,TO_DATE('21-SEP-18','DD-MON-YY'),2);
INSERT INTO STUDENT_DBR(student_id,first_name,last_name,mail,age,join_date,study_year) VALUES
(10,'Budescu','Marian','[email protected]',22,TO_DATE('09-SEP-18','DD-MON-YY'),4);
--PROF
INSERT INTO PROF_DBR(prof_id,first_name,last_name,mail,age,join_date,teach) VALUES
(1,'Girgian','Mihai','[email protected]',45,TO_DATE('20-JAN-98','DD-MON-YY'),'OOP');
INSERT INTO PROF_DBR(prof_id,first_name,last_name,mail,age,join_date,teach) VALUES
(2,'Clopotel','Maria','[email protected]',38,TO_DATE('10-DEC-99','DD-MON-YY'),'OOP');
INSERT INTO PROF_DBR(prof_id,first_name,last_name,mail,age,join_date,teach) VALUES
(3,'Radu','Andrei','[email protected]',46,TO_DATE('05-JAN-00','DD-MON-YY'),'SDA');
INSERT INTO PROF_DBR(prof_id,first_name,last_name,mail,age,join_date,teach) VALUES
(4,'Singh','Urdu','[email protected]',35,TO_DATE('18-JUL-00','DD-MON-YY'),'SDA');
INSERT INTO PROF_DBR(prof_id,first_name,last_name,mail,age,join_date,teach) VALUES
(5,'Parlog','Diana','[email protected]',42,TO_DATE('24-SEP-06','DD-MON-YY'),'AT');
INSERT INTO PROF_DBR(prof_id,first_name,last_name,mail,age,join_date,teach) VALUES
(6,'Dinescu','Mirel','[email protected]',50,TO_DATE('10-DEC-08','DD-MON-YY'),'ROBO');
INSERT INTO PROF_DBR(prof_id,first_name,last_name,mail,age,join_date,teach) VALUES
(7,'Sobrea','Daniel','[email protected]',47,TO_DATE('02-MAR-11','DD-MON-YY'),'ROBO');
INSERT INTO PROF_DBR(prof_id,first_name,last_name,mail,age,join_date,teach) VALUES
(8,'Titescu','Ion','[email protected]',44,TO_DATE('25-JUL-10','DD-MON-YY'),'AI');
INSERT INTO PROF_DBR(prof_id,first_name,last_name,mail,age,join_date,teach) VALUES
(9,'Georgescu','Radu','[email protected]',52,TO_DATE('02-DEC-00','DD-MON-YY'),'AI');
INSERT INTO PROF_DBR(prof_id,first_name,last_name,mail,age,join_date,teach) VALUES
(10,'Popescu','George','[email protected]',33,TO_DATE('10-SEP-14','DD-MON-YY'),'RPA');
--CLASSROOMS
INSERT INTO CLASSROOMS_DBR(classroom_id,floor,seats) VALUES
(1,0,50);
INSERT INTO CLASSROOMS_DBR(classroom_id,floor,seats) VALUES
(2,0,15);
INSERT INTO CLASSROOMS_DBR(classroom_id,floor,seats) VALUES
(3,0,15);
INSERT INTO CLASSROOMS_DBR(classroom_id,floor,seats) VALUES
(4,1,50);
INSERT INTO CLASSROOMS_DBR(classroom_id,floor,seats) VALUES
(5,1,20);
INSERT INTO CLASSROOMS_DBR(classroom_id,floor,seats) VALUES
(6,1,25);
INSERT INTO CLASSROOMS_DBR(classroom_id,floor,seats) VALUES
(7,2,15);
INSERT INTO CLASSROOMS_DBR(classroom_id,floor,seats) VALUES
(8,2,10);
--CLASSES
INSERT INTO CLASSES_DBR(class_id,class_name,prof_id,day_of_week,start_time,classroom) VALUES
(1,'OOP',1,1,'10:00',1);
INSERT INTO CLASSES_DBR(class_id,class_name,prof_id,day_of_week,start_time,classroom) VALUES
(2,'OOP',1,1,'12:00',1);
INSERT INTO CLASSES_DBR(class_id,class_name,prof_id,day_of_week,start_time,classroom) VALUES
(3,'OOP',1,1,'14:00',1);
INSERT INTO CLASSES_DBR(class_id,class_name,prof_id,day_of_week,start_time,classroom) VALUES
(4,'ROBO',7,1,'12:00',2);
INSERT INTO CLASSES_DBR(class_id,class_name,prof_id,day_of_week,start_time,classroom) VALUES
(5,'ROBO',6,1,'12:00',3);
INSERT INTO CLASSES_DBR(class_id,class_name,prof_id,day_of_week,start_time,classroom) VALUES
(6,'ROBO',10,1,'14:00',2);
INSERT INTO CLASSES_DBR(class_id,class_name,prof_id,day_of_week,start_time,classroom) VALUES
(7,'AT',5,2,'10:00',1);
INSERT INTO CLASSES_DBR(class_id,class_name,prof_id,day_of_week,start_time,classroom) VALUES
(8,'AT',5,2,'12:00',4);
INSERT INTO CLASSES_DBR(class_id,class_name,prof_id,day_of_week,start_time,classroom) VALUES
(9,'SDA',4,2,'12:00',2);
INSERT INTO CLASSES_DBR(class_id,class_name,prof_id,day_of_week,start_time,classroom) VALUES
(10,'AI',8,3,'10:00',2);
INSERT INTO CLASSES_DBR(class_id,class_name,prof_id,day_of_week,start_time,classroom) VALUES
(11,'AI',8,3,'12:00',1);
INSERT INTO CLASSES_DBR(class_id,class_name,prof_id,day_of_week,start_time,classroom) VALUES
(12,'OOP',1,4,'14:00',1);
INSERT INTO CLASSES_DBR(class_id,class_name,prof_id,day_of_week,start_time,classroom) VALUES
(13,'OOP',1,4,'16:00',6);
INSERT INTO CLASSES_DBR(class_id,class_name,prof_id,day_of_week,start_time,classroom) VALUES
(14,'SDA',3,5,'10:00',1);
INSERT INTO CLASSES_DBR(class_id,class_name,prof_id,day_of_week,start_time,classroom) VALUES
(15,'SDA',3,5,'12:00',1);
--REGISTER
INSERT INTO REGISTER_DBR(register_id,student_id,grade_1,grade_2,grade_3,class_name_1,class_name_2,class_name_3) VALUES
(1,1,4,6,10,'OOP','SDA','AT');
INSERT INTO REGISTER_DBR(register_id,student_id,grade_1,grade_2,grade_3,class_name_1,class_name_2,class_name_3) VALUES
(2,2,8,9,10,'OOP','SDA','AT');
INSERT INTO REGISTER_DBR(register_id,student_id,grade_1,grade_2,grade_3,class_name_1,class_name_2,class_name_3) VALUES
(3,3,2,5,6,'OOP','SDA','AT');
INSERT INTO REGISTER_DBR(register_id,student_id,grade_1,grade_2,grade_3,class_name_1,class_name_2,class_name_3) VALUES
(4,4,3,3,3,'OOP','SDA','ROBO');
INSERT INTO REGISTER_DBR(register_id,student_id,grade_1,grade_2,grade_3,class_name_1,class_name_2,class_name_3) VALUES
(5,5,10,10,10,'AI','RPA','AT');
INSERT INTO REGISTER_DBR(register_id,student_id,grade_1,grade_2,grade_3,class_name_1,class_name_2,class_name_3) VALUES
(6,6,6,8,9,'AI','RPA','AT');
INSERT INTO REGISTER_DBR(register_id,student_id,grade_1,grade_2,grade_3,class_name_1,class_name_2,class_name_3) VALUES
(7,7,9,8,9,'OOP','RPA','AI');
INSERT INTO REGISTER_DBR(register_id,student_id,grade_1,grade_2,grade_3,class_name_1,class_name_2,class_name_3) VALUES
(8,8,7,5,6,'OOP','AT','AI');
INSERT INTO REGISTER_DBR(register_id,student_id,grade_1,grade_2,grade_3,class_name_1,class_name_2,class_name_3) VALUES
(9,9,9,4,6,'OOP','ROBO','SDA');
INSERT INTO REGISTER_DBR(register_id,student_id,grade_1,grade_2,grade_3,class_name_1,class_name_2,class_name_3) VALUES
(10,10,5,5,5,'OOP','AI','SDA');