-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneration.sql
280 lines (217 loc) · 9.02 KB
/
generation.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
#------------------------------------------------------------
# Script MySQL. EXAM-PLANNER
#------------------------------------------------------------
CREATE DATABASE IF NOT EXISTS exam_planner;
use exam_planner;
#------------------------------------------------------------
# Table: Department
#------------------------------------------------------------
CREATE TABLE IF NOT EXISTS Department
(
`name` Varchar(63) NOT NULL PRIMARY KEY
) ENGINE = InnoDB;
#------------------------------------------------------------
# Table: Subject
#------------------------------------------------------------
CREATE TABLE IF NOT EXISTS Subject
(
`name` Varchar(63) NOT NULL PRIMARY KEY
) ENGINE = InnoDB;
#------------------------------------------------------------
# Table: MockUp
#------------------------------------------------------------
CREATE TABLE IF NOT EXISTS MockUp
(
`name` Varchar(63) NOT NULL PRIMARY KEY,
degree Enum ('Bachelor', 'Master') NOT NULL,
`year` Enum ('One','Two','Three') NOT NULL,
semester Enum ('One','Two') NOT NULL,
department Varchar(63) NOT NULL,
CONSTRAINT MockUp_Department_FK FOREIGN KEY (department) REFERENCES Department (`name`)
) ENGINE = InnoDB;
#------------------------------------------------------------
# Table: Slot
#------------------------------------------------------------
CREATE TABLE IF NOT EXISTS Slot
(
id CHAR(36) NOT NULL PRIMARY KEY,
`day` Date NOT NULL,
`hour` Float NOT NULL,
duration Float NOT NULL
) ENGINE = InnoDB;
#------------------------------------------------------------
# Table: Exam
#------------------------------------------------------------
CREATE TABLE IF NOT EXISTS Exam
(
id CHAR(36) NOT NULL PRIMARY KEY,
`name` Varchar(50) NOT NULL,
duration Float NOT NULL,
type Enum ('Final', 'Continuous') NOT NULL,
subject Varchar(50) NOT NULL,
CONSTRAINT Exam_Subject_FK FOREIGN KEY (subject) REFERENCES Subject (name)
) ENGINE = InnoDB;
#------------------------------------------------------------
# Table: Manager
#------------------------------------------------------------
CREATE TABLE IF NOT EXISTS Manager
(
id CHAR(36) NOT NULL PRIMARY KEY,
civility Enum ('Man','Woman','Other') NOT NULL,
lastname Varchar(63) NOT NULL,
firstname Varchar(63) NOT NULL
) ENGINE = InnoDB;
#------------------------------------------------------------
# Table: Room
#------------------------------------------------------------
CREATE TABLE IF NOT EXISTS Room
(
`name` Varchar(63) NOT NULL PRIMARY KEY,
places Int NOT NULL,
types SET (
'Amphitheater',
'ComputerRoom',
'Laboratory',
'Library',
'Office') NOT NULL,
equipments SET (
'Projector',
'Speaker',
'Board',
'Webcam'),
computerEnvironment SET (
'OfficeApplication',
'InternetAccess',
'LinuxEnvironment',
'WindowsEnvironment',
'MacOsEnvironment',
'ProgrammingApplication',
'PhysicsApplication',
'MathApplication',
'ChemistryApplication')
) ENGINE = InnoDB;
#------------------------------------------------------------
# Table: User
#------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `User`
(
id CHAR(36) NOT NULL PRIMARY KEY,
mail Varchar(100) NOT NULL,
department Varchar(63) DEFAULT NULL,
manager CHAR(36) DEFAULT NULL,
`password` Varchar(128) NOT NULL,
CONSTRAINT User_Department_FK FOREIGN KEY (department) REFERENCES Department (`name`),
CONSTRAINT User_Manager_FK FOREIGN KEY (manager) REFERENCES Manager (id)
) ENGINE = InnoDB;
#------------------------------------------------------------
# Table: _Group
#------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `Group`
(
id CHAR(36) NOT NULL PRIMARY KEY,
`name` Varchar(63) NOT NULL,
containReducedMobilityPerson Bool NOT NULL DEFAULT false,
numberOfStudentsWithoutAdjustment Int NOT NULL DEFAULT 0,
numberOfStudentsWithWritingNeeds Int NOT NULL DEFAULT 0,
numberOfStudentsWithIsolatedRooms Int NOT NULL DEFAULT 0,
numberOfStudentsWithPartTime Int NOT NULL DEFAULT 0
) ENGINE = InnoDB;
#------------------------------------------------------------
# Table: SubjectToMockUp
#------------------------------------------------------------
CREATE TABLE IF NOT EXISTS _SubjectToMockUp
(
`subject` Varchar(50) NOT NULL,
mockUp Varchar(50) NOT NULL,
CONSTRAINT SubjectToMockUp_PK PRIMARY KEY (`subject`, mockUp),
CONSTRAINT SubjectToMockUp_Subject_FK FOREIGN KEY (`subject`) REFERENCES Subject (name),
CONSTRAINT SubjectToMockUp_MockUp_FK FOREIGN KEY (mockUp) REFERENCES MockUp (name)
) ENGINE = InnoDB;
#------------------------------------------------------------
# Table: ExamToManager
#------------------------------------------------------------
CREATE TABLE IF NOT EXISTS _ExamToManager
(
exam CHAR(36) NOT NULL,
manager CHAR(36) NOT NULL,
CONSTRAINT _ExamToManager_PK PRIMARY KEY (exam, manager),
CONSTRAINT _ExamToManager_Exam_FK FOREIGN KEY (exam) REFERENCES Exam (id),
CONSTRAINT _ExamToManager_Manager_FK FOREIGN KEY (manager) REFERENCES Manager (id)
) ENGINE = InnoDB;
#------------------------------------------------------------
# Table: _ExamToExam
#------------------------------------------------------------
CREATE TABLE IF NOT EXISTS _ExamToExam
(
parent CHAR(36) NOT NULL,
child CHAR(36) NOT NULL,
CONSTRAINT _ExamToExam_PK PRIMARY KEY (parent, child),
CONSTRAINT _ExamToExam_Exam_parent_FK FOREIGN KEY (parent) REFERENCES Exam (id),
CONSTRAINT _ExamToExam_Exam_child_FK FOREIGN KEY (child) REFERENCES Exam (id)
) ENGINE = InnoDB;
#------------------------------------------------------------
# Table: _GroupToGroup
#------------------------------------------------------------
CREATE TABLE IF NOT EXISTS _GroupToGroup
(
parent CHAR(36) NOT NULL,
child CHAR(36) NOT NULL,
CONSTRAINT __GroupToGroup_PK PRIMARY KEY (parent, child),
CONSTRAINT __GroupToGroup_Group_parent_FK FOREIGN KEY (parent) REFERENCES `Group` (id),
CONSTRAINT __GroupToGroup_Group_child_FK FOREIGN KEY (child) REFERENCES `Group` (id)
) ENGINE = InnoDB;
#------------------------------------------------------------
# Table: _ExamToDepartment
#------------------------------------------------------------
CREATE TABLE IF NOT EXISTS _ExamToDepartment
(
exam CHAR(36) NOT NULL,
department Varchar(50) NOT NULL,
CONSTRAINT _ExamToDepartment_PK PRIMARY KEY (exam, department),
CONSTRAINT _ExamToDepartment_Exam_FK FOREIGN KEY (exam) REFERENCES Exam (id),
CONSTRAINT _ExamToDepartment_Department_FK FOREIGN KEY (department) REFERENCES Department (name)
) ENGINE = InnoDB;
#------------------------------------------------------------
# Table: _ExamToRoom
#------------------------------------------------------------
CREATE TABLE IF NOT EXISTS _ExamToRoom
(
exam CHAR(36) NOT NULL,
room Varchar(63) NOT NULL,
CONSTRAINT _ExamToRoom_PK PRIMARY KEY (exam, room),
CONSTRAINT _ExamToRoom_Room_FK FOREIGN KEY (room) REFERENCES Room (name),
CONSTRAINT _ExamToRoom_Exam_FK FOREIGN KEY (exam) REFERENCES Exam (id)
) ENGINE = InnoDB;
#------------------------------------------------------------
# Table: _SlotToRoom
#------------------------------------------------------------
CREATE TABLE IF NOT EXISTS _SlotToRoom
(
slot CHAR(36) NOT NULL,
room Varchar(63) NOT NULL,
CONSTRAINT _SlotToRoom_PK PRIMARY KEY (slot, room),
CONSTRAINT _SlotToRoom_Room_FK FOREIGN KEY (room) REFERENCES Room (name),
CONSTRAINT _SlotToRoom_Exam_FK FOREIGN KEY (slot) REFERENCES Slot (id)
) ENGINE = InnoDB;
#------------------------------------------------------------
# Table: _ExamToGroup
#------------------------------------------------------------
CREATE TABLE IF NOT EXISTS _ExamToGroup
(
exam CHAR(36) NOT NULL,
`group` CHAR(36) NOT NULL,
CONSTRAINT _ExamToGroup_PK PRIMARY KEY (exam, `group`),
CONSTRAINT _ExamToGroup_Exam_FK FOREIGN KEY (exam) REFERENCES Exam (id),
CONSTRAINT _ExamToGroup_Group_FK FOREIGN KEY (`group`) REFERENCES `Group` (id)
) ENGINE = InnoDB;
#------------------------------------------------------------
# Table: _ExamToSlot
#------------------------------------------------------------
CREATE TABLE IF NOT EXISTS _ExamToSlot
(
exam CHAR(36) NOT NULL,
slot CHAR(36) NOT NULL,
CONSTRAINT _ExamToSlot_PK PRIMARY KEY (exam, slot),
CONSTRAINT _ExamToSlot_Exam_FK FOREIGN KEY (exam) REFERENCES Exam (id),
CONSTRAINT _ExamToSlot_Group_FK FOREIGN KEY (slot) REFERENCES Slot (id)
) ENGINE = InnoDB;