-
Notifications
You must be signed in to change notification settings - Fork 1
/
database_schema.sql
314 lines (259 loc) · 10.6 KB
/
database_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
306
307
308
309
310
311
312
313
314
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
CREATE TABLE `cat2cri` (
`nC2CId` int(11) UNSIGNED NOT NULL,
`nCatId` int(11) UNSIGNED NOT NULL DEFAULT '0',
`nCriId` int(11) UNSIGNED NOT NULL DEFAULT '0',
`nSort` int(11) UNSIGNED NOT NULL,
`dCreate` int(35) UNSIGNED NOT NULL,
`dUpdate` int(35) UNSIGNED NOT NULL,
`bArchive` tinyint(2) UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
CREATE TABLE `catalogue` (
`nCatId` int(11) UNSIGNED NOT NULL,
`nUseId` int(11) UNSIGNED NOT NULL,
`sName` text NOT NULL,
`sNote` text NOT NULL,
`dCreate` int(35) UNSIGNED NOT NULL,
`dUpdate` int(35) UNSIGNED NOT NULL,
`bArchive` tinyint(2) UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
CREATE TABLE `course` (
`nCouId` int(11) UNSIGNED NOT NULL,
`nUseId` int(11) UNSIGNED NOT NULL,
`sName` text NOT NULL,
`nWidth` int(3) UNSIGNED DEFAULT NULL,
`nHeight` int(3) UNSIGNED DEFAULT NULL,
`dCreate` int(35) UNSIGNED NOT NULL,
`dUpdate` int(35) UNSIGNED NOT NULL,
`sCategory` text NOT NULL,
`bArchive` tinyint(2) UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `criteria` (
`nCriId` int(11) UNSIGNED NOT NULL,
`sName` varchar(50) NOT NULL,
`sNote` text NOT NULL,
`nMin` int(5) NOT NULL DEFAULT '1',
`nMax` int(5) NOT NULL DEFAULT '10',
`bOptional` tinyint(2) UNSIGNED NOT NULL DEFAULT '0',
`dCreate` int(35) UNSIGNED NOT NULL,
`dUpdate` int(35) UNSIGNED NOT NULL,
`bArchive` tinyint(2) UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
CREATE TABLE `email` (
`nEmaId` int(11) UNSIGNED NOT NULL,
`nUseId` int(11) UNSIGNED NOT NULL,
`nRecipientUseId` int(11) UNSIGNED DEFAULT NULL,
`nRecipientStuId` int(11) UNSIGNED DEFAULT NULL,
`sRecipient` text NOT NULL,
`sSubject` text NOT NULL,
`sMail` text NOT NULL,
`sHeader` text NOT NULL,
`dCreate` int(35) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
CREATE TABLE `grade` (
`nGraId` int(11) UNSIGNED NOT NULL,
`nC2CId` int(11) UNSIGNED NOT NULL,
`nS2RId` int(11) UNSIGNED NOT NULL,
`fPoints` decimal(5,2) UNSIGNED DEFAULT NULL,
`sNote` text NOT NULL,
`dCreate` int(35) UNSIGNED NOT NULL,
`dUpdate` int(35) UNSIGNED NOT NULL,
`bArchive` tinyint(2) UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
CREATE TABLE `rating` (
`nRatId` int(11) UNSIGNED NOT NULL,
`sName` varchar(50) NOT NULL,
`sNote` text NOT NULL,
`nCouId` int(11) UNSIGNED NOT NULL,
`nCatId` int(11) UNSIGNED NOT NULL,
`nSysId` int(11) UNSIGNED NOT NULL,
`fWeight` decimal(5,2) UNSIGNED NOT NULL,
`nSort` int(11) UNSIGNED NOT NULL,
`dCreate` int(35) UNSIGNED NOT NULL,
`dUpdate` int(35) UNSIGNED NOT NULL,
`bArchive` tinyint(2) UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
CREATE TABLE `stu2cou` (
`nS2CId` int(11) UNSIGNED NOT NULL,
`nStuId` int(11) UNSIGNED NOT NULL,
`nCouId` int(11) UNSIGNED NOT NULL,
`fGrade` decimal(5,2) UNSIGNED DEFAULT NULL,
`bGradeManual` tinyint(2) UNSIGNED NOT NULL DEFAULT '0',
`nPosX` int(2) UNSIGNED DEFAULT NULL,
`nPosY` int(2) UNSIGNED DEFAULT NULL,
`dCreate` int(35) UNSIGNED NOT NULL,
`dUpdate` int(35) UNSIGNED NOT NULL,
`bArchive` tinyint(2) UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
CREATE TABLE `stu2rat` (
`nS2RId` int(11) UNSIGNED NOT NULL,
`nS2CId` int(11) UNSIGNED NOT NULL,
`nRatId` int(11) UNSIGNED NOT NULL,
`fGrade` decimal(5,2) DEFAULT NULL,
`nTry` int(2) UNSIGNED NOT NULL DEFAULT '1',
`sNote` text NOT NULL,
`nCorrectionDuration` int(35) UNSIGNED NOT NULL DEFAULT '0',
`bDone` tinyint(2) UNSIGNED NOT NULL DEFAULT '0',
`dCreate` int(35) UNSIGNED NOT NULL,
`dUpdate` int(35) UNSIGNED NOT NULL,
`bArchive` tinyint(2) UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
CREATE TABLE `student` (
`nStuId` int(11) UNSIGNED NOT NULL,
`nUseId` int(11) UNSIGNED NOT NULL,
`sName` text NOT NULL,
`sMail` text NOT NULL,
`sNr` text NOT NULL,
`sNote` text NOT NULL,
`sImage` mediumtext NOT NULL,
`dCreate` int(35) UNSIGNED NOT NULL,
`dUpdate` int(35) UNSIGNED NOT NULL,
`bArchive` tinyint(2) UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
CREATE TABLE `system` (
`nSysId` int(11) UNSIGNED NOT NULL,
`sGroup` varchar(100) NOT NULL,
`sName` varchar(100) NOT NULL,
`sGrade` varchar(150) NOT NULL,
`sGradeBest` varchar(30) NOT NULL,
`sGradeFail` varchar(50) NOT NULL,
`dCreate` int(35) UNSIGNED NOT NULL,
`dUpdate` int(35) UNSIGNED NOT NULL,
`bArchive` tinyint(2) UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
CREATE TABLE `talk` (
`nTalId` int(11) UNSIGNED NOT NULL,
`nUseId` int(11) UNSIGNED NOT NULL,
`nStuId` int(11) UNSIGNED DEFAULT NULL,
`sName` text NOT NULL,
`sNote` text NOT NULL,
`dCreate` int(35) UNSIGNED NOT NULL,
`dUpdate` int(35) UNSIGNED NOT NULL,
`bArchive` tinyint(2) UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
CREATE TABLE `user` (
`nUseId` int(11) UNSIGNED NOT NULL,
`sUser` varchar(50) NOT NULL,
`sName` text NOT NULL,
`sMail` text NOT NULL,
`sPassword` varchar(100) NOT NULL,
`bOfflineSync` tinyint(2) UNSIGNED NOT NULL DEFAULT '0',
`eLanguage` enum('de_DE') NOT NULL DEFAULT 'de_DE',
`eDialect` enum('school','university') NOT NULL DEFAULT 'school',
`dCreate` int(35) UNSIGNED NOT NULL,
`dUpdate` int(35) UNSIGNED NOT NULL,
`bArchive` tinyint(2) UNSIGNED NOT NULL DEFAULT '0',
`bAdmin` tinyint(2) UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `cat2cri`
ADD PRIMARY KEY (`nC2CId`),
ADD KEY `cat2cri catalogue` (`nCatId`),
ADD KEY `cat2cri criteria` (`nCriId`);
ALTER TABLE `catalogue`
ADD PRIMARY KEY (`nCatId`),
ADD KEY `catalogue-user` (`nUseId`);
ALTER TABLE `course`
ADD PRIMARY KEY (`nCouId`),
ADD KEY `course-user` (`nUseId`);
ALTER TABLE `criteria`
ADD PRIMARY KEY (`nCriId`);
ALTER TABLE `email`
ADD PRIMARY KEY (`nEmaId`),
ADD KEY `email-user` (`nUseId`),
ADD KEY `email-recipient_user` (`nRecipientUseId`),
ADD KEY `email-recipient_student` (`nRecipientStuId`);
ALTER TABLE `grade`
ADD PRIMARY KEY (`nGraId`),
ADD KEY `grade cat2cri` (`nC2CId`),
ADD KEY `grade stu2rat` (`nS2RId`);
ALTER TABLE `rating`
ADD PRIMARY KEY (`nRatId`),
ADD KEY `rating course` (`nCouId`),
ADD KEY `rating catalogue` (`nCatId`),
ADD KEY `rating system` (`nSysId`);
ALTER TABLE `stu2cou`
ADD PRIMARY KEY (`nS2CId`),
ADD KEY `nStuId_nCouId` (`nStuId`,`nCouId`),
ADD KEY `stu2cou course` (`nCouId`);
ALTER TABLE `stu2rat`
ADD PRIMARY KEY (`nS2RId`),
ADD KEY `stu2rat rating` (`nRatId`),
ADD KEY `stu2rat stu2cou` (`nS2CId`);
ALTER TABLE `student`
ADD PRIMARY KEY (`nStuId`),
ADD KEY `student-user` (`nUseId`);
ALTER TABLE `system`
ADD PRIMARY KEY (`nSysId`);
ALTER TABLE `talk`
ADD PRIMARY KEY (`nTalId`),
ADD KEY `talk-user` (`nUseId`),
ADD KEY `talk-student` (`nStuId`);
ALTER TABLE `user`
ADD PRIMARY KEY (`nUseId`),
ADD UNIQUE KEY `sName` (`sUser`,`bArchive`);
ALTER TABLE `cat2cri`
MODIFY `nC2CId` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `catalogue`
MODIFY `nCatId` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `course`
MODIFY `nCouId` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `criteria`
MODIFY `nCriId` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `email`
MODIFY `nEmaId` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `grade`
MODIFY `nGraId` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `rating`
MODIFY `nRatId` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `stu2cou`
MODIFY `nS2CId` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `stu2rat`
MODIFY `nS2RId` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `student`
MODIFY `nStuId` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `system`
MODIFY `nSysId` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `talk`
MODIFY `nTalId` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `user`
MODIFY `nUseId` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `cat2cri`
ADD CONSTRAINT `cat2cri catalogue` FOREIGN KEY (`nCatId`) REFERENCES `catalogue` (`nCatId`),
ADD CONSTRAINT `cat2cri criteria` FOREIGN KEY (`nCriId`) REFERENCES `criteria` (`nCriId`);
ALTER TABLE `catalogue`
ADD CONSTRAINT `catalogue-user` FOREIGN KEY (`nUseId`) REFERENCES `user` (`nUseId`);
ALTER TABLE `course`
ADD CONSTRAINT `course-user` FOREIGN KEY (`nUseId`) REFERENCES `user` (`nUseId`);
ALTER TABLE `email`
ADD CONSTRAINT `email-recipient_student` FOREIGN KEY (`nRecipientStuId`) REFERENCES `student` (`nStuId`),
ADD CONSTRAINT `email-recipient_user` FOREIGN KEY (`nRecipientUseId`) REFERENCES `user` (`nUseId`),
ADD CONSTRAINT `email-user` FOREIGN KEY (`nUseId`) REFERENCES `user` (`nUseId`);
ALTER TABLE `grade`
ADD CONSTRAINT `grade cat2cri` FOREIGN KEY (`nC2CId`) REFERENCES `cat2cri` (`nC2CId`),
ADD CONSTRAINT `grade stu2rat` FOREIGN KEY (`nS2RId`) REFERENCES `stu2rat` (`nS2RId`);
ALTER TABLE `rating`
ADD CONSTRAINT `rating catalogue` FOREIGN KEY (`nCatId`) REFERENCES `catalogue` (`nCatId`),
ADD CONSTRAINT `rating course` FOREIGN KEY (`nCouId`) REFERENCES `course` (`nCouId`),
ADD CONSTRAINT `rating system` FOREIGN KEY (`nSysId`) REFERENCES `system` (`nSysId`);
ALTER TABLE `stu2cou`
ADD CONSTRAINT `stu2cou course` FOREIGN KEY (`nCouId`) REFERENCES `course` (`nCouId`),
ADD CONSTRAINT `stu2cou student` FOREIGN KEY (`nStuId`) REFERENCES `student` (`nStuId`);
ALTER TABLE `stu2rat`
ADD CONSTRAINT `stu2rat rating` FOREIGN KEY (`nRatId`) REFERENCES `rating` (`nRatId`),
ADD CONSTRAINT `stu2rat stu2cou` FOREIGN KEY (`nS2CId`) REFERENCES `stu2cou` (`nS2CId`);
ALTER TABLE `student`
ADD CONSTRAINT `student-user` FOREIGN KEY (`nUseId`) REFERENCES `user` (`nUseId`);
ALTER TABLE `talk`
ADD CONSTRAINT `talk-student` FOREIGN KEY (`nStuId`) REFERENCES `student` (`nStuId`),
ADD CONSTRAINT `talk-user` FOREIGN KEY (`nUseId`) REFERENCES `user` (`nUseId`);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;