blob: 64837a63674553e2f3a1912201d3407febb0856d [file] [log] [blame]
avm9996370995382020-09-23 01:03:01 +02001-- SQL sentences to set up all the DB tables
2
3CREATE TABLE users (
4 id INT NOT NULL AUTO_INCREMENT,
5 PRIMARY KEY(id),
6 sub VARCHAR(255) NOT NULL UNIQUE,
7 email VARCHAR(320)
8);
9
10CREATE TABLE subjects (
11 id INT NOT NULL AUTO_INCREMENT,
12 PRIMARY KEY(id),
13 friendly_name VARCHAR(100) NOT NULL UNIQUE, -- Nom que es mostra al web
avm99963472b0de2020-09-28 17:15:42 +020014 calendar_name VARCHAR(100) NOT NULL, -- Nom al calendari de la FME
15 INDEX(calendar_name)
avm9996370995382020-09-23 01:03:01 +020016);
17
18CREATE TABLE user_subjects (
19 id INT NOT NULL AUTO_INCREMENT,
20 PRIMARY KEY(id),
21 user_id INT NOT NULL,
avm99963472b0de2020-09-28 17:15:42 +020022 INDEX(user_id),
avm9996370995382020-09-23 01:03:01 +020023 subject_id INT NOT NULL
24);
25
avm9996361ed9e52020-09-28 00:02:27 +020026CREATE TABLE classes (
27 id INT NOT NULL AUTO_INCREMENT,
28 PRIMARY KEY(id),
29 calendar_name VARCHAR(100) NOT NULL,
avm99963472b0de2020-09-28 17:15:42 +020030 INDEX(calendar_name),
avm9996361ed9e52020-09-28 00:02:27 +020031 room VARCHAR(10) NOT NULL,
avm9996359ba3432020-09-28 19:03:29 +020032 begins INT NOT NULL, -- UNIX timestamp de l'hora d'inici
avm99963472b0de2020-09-28 17:15:42 +020033 INDEX(begins),
avm9996359ba3432020-09-28 19:03:29 +020034 ends INT NOT NULL, -- UNIX timestamp de l'hora de fi
avm99963472b0de2020-09-28 17:15:42 +020035 INDEX(ends)
avm9996361ed9e52020-09-28 00:02:27 +020036);
37
avm9996370995382020-09-23 01:03:01 +020038-- @TODO: Add form completion log table