-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQLschema.sql
More file actions
404 lines (396 loc) · 10.6 KB
/
SQLschema.sql
File metadata and controls
404 lines (396 loc) · 10.6 KB
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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
-- Setting up the database
CREATE DATABASE ACMSPro_Main;
USE ACMSPro_Main;
-- DDL
-- no foreign KEY
CREATE TABLE Course(
course_id varchar(16) NOT NULL PRIMARY KEY,
course_name varchar(128) NOT NULL
);
CREATE TABLE Countries(
country_id char(3) NOT NULL PRIMARY KEY,
country_name varchar(64)
);
CREATE TABLE AdminUser(
admin_id int(8) NOT NULL PRIMARY KEY,
first_name varchar(64) NOT NULL,
middle_name varchar(64),
last_name varchar(64) NOT NULL,
title varchar(64),
password_hash char(64) NOT NULL,
salt char(8) NOT NULL
);
-- refrencesed tables
CREATE TABLE StudentUser(
student_id int(8) NOT NULL PRIMARY KEY,
first_name varchar(64) NOT NULL,
middle_name varchar(64),
last_name varchar(64) NOT NULL,
course_id varchar(16) NOT NULL,
intake varchar(16),
password_hash char(64) NOT NULL,
salt char(8) NOT NULL,
blocked bit(1) default 0,
FOREIGN KEY (course_id) REFERENCES Course(course_id)
);
CREATE TABLE PendingStudentUser(
student_id int(8) NOT NULL,
reg_id int(8),
first_name varchar(64) NOT NULL,
middle_name varchar(64),
last_name varchar(64) NOT NULL,
course_id varchar(16) NOT NULL,
intake varchar(16),
pending tinyint(1) default 1,
password_hash char(64) NOT NULL,
salt char(8) NOT NULL,
PRIMARY KEY(student_id, reg_id),
FOREIGN KEY (course_id) REFERENCES Course(course_id)
);
CREATE TABLE Bookmarks(
student_id int(8) NOT NULL,
bookmark_index int(4) NOT NULL,
target_id int(8) NOT NULL,
PRIMARY KEY(student_id, bookmark_index),
FOREIGN KEY (student_id) REFERENCES StudentUser(student_id),
FOREIGN KEY (target_id) REFERENCES StudentUser(student_id)
);
CREATE TABLE Emails(
student_id int(8) NOT NULL,
email_index int(8) NOT NULL,
email varchar(64) NOT NULL,
description text,
isHidden bit(1) default 0,
PRIMARY KEY (student_id,email_index),
FOREIGN KEY (student_id) REFERENCES StudentUser(student_id)
);
CREATE TABLE PhoneNum(
student_id int(8) NOT NULL,
phoneNum_index int(8) NOT NULL,
phoneNum varchar(64) NOT NULL,
description text,
isHidden bit(1) default 0,
PRIMARY KEY (student_id,phoneNum_index),
FOREIGN KEY (student_id) REFERENCES StudentUser(student_id)
);
CREATE TABLE Address(
student_id int(8) NOT NULL,
address_index int(8) NOT NULL,
address_line1 text NOT NULL,
address_line2 text,
city varchar(64),
state_province varchar(64),
country_id char(3) NOT NULL,
description text,
isHidden bit(1) default 0,
PRIMARY KEY (student_id,address_index),
FOREIGN KEY (student_id) REFERENCES StudentUser(student_id),
FOREIGN KEY (country_id) REFERENCES Countries(country_id)
);
CREATE TABLE PasswordToken(
token varchar(64),
student_id int(8),
PRIMARY KEY (token),
FOREIGN KEY (student_id) REFERENCES StudentUser(student_id)
);
CREATE TABLE Messages(
sender_id int(8) NOT NULL,
target_id int(8) NOT NULL,
msg_index int(8) NOT NULL,
title varchar(256),
content longtext,
send_date date NOT NULL,
is_read bit(0) NOT NULL DEFAULT 0,
PRIMARY KEY (sender_id, target_id, msg_index)
);
-- DML (Pre-set values)
insert into Countries(country_name,country_id) values
("Afghanistan","AFG"),
("Aland Islands","ALA"),
("Albania","ALB"),
("Algeria","DZA"),
("American Samoa","ASM"),
("Andorra","AND"),
("Angola","AGO"),
("Anguilla","AIA"),
("Antarctica","ATA"),
("Antigua and Barbuda","ATG"),
("Argentina","ARG"),
("Armenia","ARM"),
("Aruba","ABW"),
("Australia","AUS"),
("Austria","AUT"),
("Azerbaijan","AZE"),
("Bahamas","BHS"),
("Bahrain","BHR"),
("Bangladesh","BGD"),
("Barbados","BRB"),
("Belarus","BLR"),
("Belgium","BEL"),
("Belize","BLZ"),
("Benin","BEN"),
("Bermuda","BMU"),
("Bhutan","BTN"),
("Bolivia","BOL"),
("Bosnia and Herzegovina","BIH"),
("Botswana","BWA"),
("Bouvet Island","BVT"),
("Brazil","BRA"),
("British Virgin Islands","VGB"),
("British Indian Ocean Territory","IOT"),
("Brunei Darussalam","BRN"),
("Bulgaria","BGR"),
("Burkina Faso","BFA"),
("Burundi","BDI"),
("Cambodia","KHM"),
("Cameroon","CMR"),
("Canada","CAN"),
("Cape Verde","CPV"),
("Cayman Islands","CYM"),
("Central African Republic","CAF"),
("Chad","TCD"),
("Chile","CHL"),
("China","CHN"),
("Hong Kong, SAR China","HKG"),
("Macao, SAR China","MAC"),
("Christmas Island","CXR"),
("Cocos (Keeling) Islands","CCK"),
("Colombia","COL"),
("Comoros","COM"),
("Congo (Brazzaville)","COG"),
("Congo, (Kinshasa)","COD"),
("Cook Islands","COK"),
("Costa Rica","CRI"),
("Côte d'Ivoire","CIV"),
("Croatia","HRV"),
("Cuba","CUB"),
("Cyprus","CYP"),
("Czech Republic","CZE"),
("Denmark","DNK"),
("Djibouti","DJI"),
("Dominica","DMA"),
("Dominican Republic","DOM"),
("Ecuador","ECU"),
("Egypt","EGY"),
("El Salvador","SLV"),
("Equatorial Guinea","GNQ"),
("Eritrea","ERI"),
("Estonia","EST"),
("Ethiopia","ETH"),
("Falkland Islands (Malvinas)","FLK"),
("Faroe Islands","FRO"),
("Fiji","FJI"),
("Finland","FIN"),
("France","FRA"),
("French Guiana","GUF"),
("French Polynesia","PYF"),
("French Southern Territories","ATF"),
("Gabon","GAB"),
("Gambia","GMB"),
("Georgia","GEO"),
("Germany","DEU"),
("Ghana","GHA"),
("Gibraltar","GIB"),
("Greece","GRC"),
("Greenland","GRL"),
("Grenada","GRD"),
("Guadeloupe","GLP"),
("Guam","GUM"),
("Guatemala","GTM"),
("Guernsey","GGY"),
("Guinea","GIN"),
("Guinea-Bissau","GNB"),
("Guyana","GUY"),
("Haiti","HTI"),
("Heard and Mcdonald Islands","HMD"),
("Holy See (Vatican City State)","VAT"),
("Honduras","HND"),
("Hungary","HUN"),
("Iceland","ISL"),
("India","IND"),
("Indonesia","IDN"),
("Iran, Islamic Republic of","IRN"),
("Iraq","IRQ"),
("Ireland","IRL"),
("Isle of Man","IMN"),
("Israel","ISR"),
("Italy","ITA"),
("Jamaica","JAM"),
("Japan","JPN"),
("Jersey","JEY"),
("Jordan","JOR"),
("Kazakhstan","KAZ"),
("Kenya","KEN"),
("Kiribati","KIR"),
("Korea (North)","PRK"),
("Korea (South)","KOR"),
("Kuwait","KWT"),
("Kyrgyzstan","KGZ"),
("Lao PDR","LAO"),
("Latvia","LVA"),
("Lebanon","LBN"),
("Lesotho","LSO"),
("Liberia","LBR"),
("Libya","LBY"),
("Liechtenstein","LIE"),
("Lithuania","LTU"),
("Luxembourg","LUX"),
("Macedonia, Republic of","MKD"),
("Madagascar","MDG"),
("Malawi","MWI"),
("Malaysia","MYS"),
("Maldives","MDV"),
("Mali","MLI"),
("Malta","MLT"),
("Marshall Islands","MHL"),
("Martinique","MTQ"),
("Mauritania","MRT"),
("Mauritius","MUS"),
("Mayotte","MYT"),
("Mexico","MEX"),
("Micronesia, Federated States of","FSM"),
("Moldova","MDA"),
("Monaco","MCO"),
("Mongolia","MNG"),
("Montenegro","MNE"),
("Montserrat","MSR"),
("Morocco","MAR"),
("Mozambique","MOZ"),
("Myanmar","MMR"),
("Namibia","NAM"),
("Nauru","NRU"),
("Nepal","NPL"),
("Netherlands","NLD"),
("Netherlands Antilles","ANT"),
("New Caledonia","NCL"),
("New Zealand","NZL"),
("Nicaragua","NIC"),
("Niger","NER"),
("Nigeria","NGA"),
("Niue","NIU"),
("Norfolk Island","NFK"),
("Northern Mariana Islands","MNP"),
("Norway","NOR"),
("Oman","OMN"),
("Pakistan","PAK"),
("Palau","PLW"),
("Palestinian Territory","PSE"),
("Panama","PAN"),
("Papua New Guinea","PNG"),
("Paraguay","PRY"),
("Peru","PER"),
("Philippines","PHL"),
("Pitcairn","PCN"),
("Poland","POL"),
("Portugal","PRT"),
("Puerto Rico","PRI"),
("Qatar","QAT"),
("Réunion","REU"),
("Romania","ROU"),
("Russian Federation","RUS"),
("Rwanda","RWA"),
("Saint-Barthélemy","BLM"),
("Saint Helena","SHN"),
("Saint Kitts and Nevis","KNA"),
("Saint Lucia","LCA"),
("Saint-Martin (French part)","MAF"),
("Saint Pierre and Miquelon","SPM"),
("Saint Vincent and Grenadines","VCT"),
("Samoa","WSM"),
("San Marino","SMR"),
("Sao Tome and Principe","STP"),
("Saudi Arabia","SAU"),
("Senegal","SEN"),
("Serbia","SRB"),
("Seychelles","SYC"),
("Sierra Leone","SLE"),
("Singapore","SGP"),
("Slovakia","SVK"),
("Slovenia","SVN"),
("Solomon Islands","SLB"),
("Somalia","SOM"),
("South Africa","ZAF"),
("South Georgia and the South Sandwich Islands","SGS"),
("South Sudan","SSD"),
("Spain","ESP"),
("Sri Lanka","LKA"),
("Sudan","SDN"),
("Suriname","SUR"),
("Svalbard and Jan Mayen Islands","SJM"),
("Swaziland","SWZ"),
("Sweden","SWE"),
("Switzerland","CHE"),
("Syrian Arab Republic (Syria)","SYR"),
("Taiwan (R.O.C)","TWN"),
("Tajikistan","TJK"),
("Tanzania, United Republic of","TZA"),
("Thailand","THA"),
("Timor-Leste","TLS"),
("Togo","TGO"),
("Tokelau","TKL"),
("Tonga","TON"),
("Trinidad and Tobago","TTO"),
("Tunisia","TUN"),
("TurKEY","TUR"),
("Turkmenistan","TKM"),
("Turks and Caicos Islands","TCA"),
("Tuvalu","TUV"),
("Uganda","UGA"),
("Ukraine","UKR"),
("United Arab Emirates","ARE"),
("United Kingdom","GBR"),
("United States of America","USA"),
("US Minor Outlying Islands","UMI"),
("Uruguay","URY"),
("Uzbekistan","UZB"),
("Vanuatu","VUT"),
("Venezuela (Bolivarian Republic)","VEN"),
("Viet Nam","VNM"),
("Virgin Islands, US","VIR"),
("Wallis and Futuna Islands","WLF"),
("Western Sahara","ESH"),
("Yemen","YEM"),
("Zambia","ZMB"),
("Zimbabwe","ZWE");
insert into Course values
("ACCA","ACCA Qualification"),
("AFIA","ACCA Foundation in Accountancy"),
("ALE","Cambridge GCE Advanced Level"),
("ALE(HS)","Cambridge GCE Advanced Level Head Start"),
("AUSMA","Australian Matriculation Programme"),
("AUSMA(HS)","Australian Matriculation Programme Head Start"),
("CAT","Certified Accounting Technician"),
("CBS","Certificate in Business Studies"),
("CFAB","Certificate in Finance, Accounting and Business"),
("CIMP","Canadian International Matriculation Programme (CIMP)"),
("CIMP(HS)","Canadian International Matriculation Programme (CIMP) Head Start"),
("DACC","Diploma in Accounting"),
("DBA","Diploma in Business Administration"),
("DCOM","Diploma in Communication"),
("DCSI","Diploma in Computer Science"),
("DFIN","Diploma in Finance"),
("DIIT","Diploma in Information Technology"),
("DINM","Diploma in Interactive New Media"),
("DPAC","Diploma in Professional Accounting"),
("FCEO(CAT)","Future CEO Certified Accounting Technician"),
("FCEO(CFAB)","Future CEO Certificate in Finance, Accounting and Business"),
("FEP","Foundation English Programme "),
("FIA","Foundation in Arts"),
("FIA(HS)","Foundation in Arts Head Start"),
("FIST","Foundation in Science and Technology"),
("FIST(HS)","Foundation in Science and Technology Head Start"),
("GIFPR","Global Issues for the Finance Professional"),
("GL","German Language Preparatory Programm"),
("ICAEW","Institute of Chartered Accountants in England and Wales (ICAEW)"),
("MUFY","Monash University Foundation Year"),
("MUFY(HS)","Monash University Foundation Year Head Start"),
("SC-ACA","ACA USM"),
("SFMGT","Strategic Financial Management"),
("SFPRO","Strategic Financial Project"),
("SPMGT","Strategic Performance Management"),
("VUBU","Bachelor of Business 3+0 in Collaboration with Victoria University of Melbourne, Australi"),
("VUENG","English for Business' Enrichment Programme"),
("VUMB(ERPS)","Master of Business (Enterprise Resource Planning Systems) in Collaboration with Victoria "),
("VUMBA","Master of Business Administration in Collaboration with Victoria University, Australia"),
("VUSUMMER","Bachelor of Business - Summer School"),
("WHK-ACCA","ACCA WORKSHOP");