-
Notifications
You must be signed in to change notification settings - Fork 0
/
create.sql
155 lines (136 loc) · 4.05 KB
/
create.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
USE c_cs108_tjsavage;
CREATE TABLE IF NOT EXISTS users(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
username VARCHAR(40) NOT NULL,
password VARCHAR(65) NOT NULL,
isAdmin INT
);
CREATE TABLE IF NOT EXISTS friends_join(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
friend1ID INT UNSIGNED NOT NULL REFERENCES users(id),
friend2ID INT UNSIGNED NOT NULL REFERENCES users(id)
);
CREATE TABLE IF NOT EXISTS friend_requests(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
friendFromID INT UNSIGNED NOT NULL REFERENCES users(id),
friendToID INT UNSIGNED NOT NULL REFERENCES users(id),
date_sent TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS messages(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
friendFromID INT UNSIGNED NOT NULL REFERENCES users(id),
friendToID INT UNSIGNED NOT NULL REFERENCES users(id),
message TEXT,
readMark BOOLEAN,
date_sent TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS challenges(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
friendFromID INT UNSIGNED NOT NULL REFERENCES users(id),
friendToID INT UNSIGNED NOT NULL REFERENCES users(id),
quizID INT UNSIGNED,
completed BOOLEAN,
date_sent TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS achievementsAwarded(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
userID INT UNSIGNED NOT NULL REFERENCES users(id),
achievementID INT UNSIGNED NOT NULL REFERENCES achievements(id),
date_sent TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS achievements(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
title TEXT,
description TEXT
);
CREATE TABLE IF NOT EXISTS anouncements(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
adminID INT UNSIGNED NOT NULL,
anouncement TEXT,
isAdminOnly INT,
date_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS terminated_users(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
userID INT UNSIGNED NOT NULL,
username TEXT,
reason TEXT,
adminID INT UNSIGNED NOT NULL
);
CREATE TABLE IF NOT EXISTS images(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
userID INT UNSIGNED NOT NULL,
url TEXT,
isProfile INT,
date_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS quizzes(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
name VARCHAR(40) NOT NULL,
description TEXT,
creator INT UNSIGNED NOT NULL REFERENCES users(id),
ordered BOOLEAN,
multi_page BOOLEAN,
immediate_correction BOOLEAN DEFAULT false,
date_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS questions(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
quizID INT UNSIGNED NOT NULL REFERENCES quizzes(id),
question_type INT NOT NULL,
specific_questionID INT UNSIGNED NOT NULL,
order_index INT
);
CREATE TABLE IF NOT EXISTS question_response_questions(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
question_text TEXT
);
CREATE TABLE IF NOT EXISTS fill_in_questions(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
question_text TEXT
);
CREATE TABLE IF NOT EXISTS multiple_choice_questions(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
question_text TEXT
);
CREATE TABLE IF NOT EXISTS multiple_choice_choices(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
specific_questionID INT UNSIGNED NOT NULL REFERENCES multiple_choice_questions(id),
choice VARCHAR(60)
);
CREATE TABLE IF NOT EXISTS picture_response_questions(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
question_text TEXT
);
CREATE TABLE IF NOT EXISTS answers(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
questionID INT UNSIGNED NOT NULL REFERENCES questions(id),
answer VARCHAR(60)
);
CREATE TABLE IF NOT EXISTS quiz_results(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
quizID INT UNSIGNED NOT NULL REFERENCES quizzes(id),
userID INT UNSIGNED NOT NULL REFERENCES users(id),
score INT,
completion_time INT,
date_taken TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);