avm99963 | 7099538 | 2020-09-23 01:03:01 +0200 | [diff] [blame] | 1 | -- SQL sentences to set up all the DB tables |
| 2 | |
| 3 | CREATE 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 | |
| 10 | CREATE 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 |
avm99963 | 472b0de | 2020-09-28 17:15:42 +0200 | [diff] [blame] | 14 | calendar_name VARCHAR(100) NOT NULL, -- Nom al calendari de la FME |
| 15 | INDEX(calendar_name) |
avm99963 | 7099538 | 2020-09-23 01:03:01 +0200 | [diff] [blame] | 16 | ); |
| 17 | |
| 18 | CREATE TABLE user_subjects ( |
| 19 | id INT NOT NULL AUTO_INCREMENT, |
| 20 | PRIMARY KEY(id), |
| 21 | user_id INT NOT NULL, |
avm99963 | 472b0de | 2020-09-28 17:15:42 +0200 | [diff] [blame] | 22 | INDEX(user_id), |
avm99963 | 7099538 | 2020-09-23 01:03:01 +0200 | [diff] [blame] | 23 | subject_id INT NOT NULL |
| 24 | ); |
| 25 | |
avm99963 | 61ed9e5 | 2020-09-28 00:02:27 +0200 | [diff] [blame] | 26 | CREATE TABLE classes ( |
| 27 | id INT NOT NULL AUTO_INCREMENT, |
| 28 | PRIMARY KEY(id), |
| 29 | calendar_name VARCHAR(100) NOT NULL, |
avm99963 | 472b0de | 2020-09-28 17:15:42 +0200 | [diff] [blame] | 30 | INDEX(calendar_name), |
avm99963 | 61ed9e5 | 2020-09-28 00:02:27 +0200 | [diff] [blame] | 31 | room VARCHAR(10) NOT NULL, |
avm99963 | 59ba343 | 2020-09-28 19:03:29 +0200 | [diff] [blame] | 32 | begins INT NOT NULL, -- UNIX timestamp de l'hora d'inici |
avm99963 | 472b0de | 2020-09-28 17:15:42 +0200 | [diff] [blame] | 33 | INDEX(begins), |
avm99963 | 59ba343 | 2020-09-28 19:03:29 +0200 | [diff] [blame] | 34 | ends INT NOT NULL, -- UNIX timestamp de l'hora de fi |
avm99963 | 472b0de | 2020-09-28 17:15:42 +0200 | [diff] [blame] | 35 | INDEX(ends) |
avm99963 | 61ed9e5 | 2020-09-28 00:02:27 +0200 | [diff] [blame] | 36 | ); |
| 37 | |
avm99963 | 7099538 | 2020-09-23 01:03:01 +0200 | [diff] [blame] | 38 | -- @TODO: Add form completion log table |