summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/schema.sql10
-rw-r--r--sql/tcourse.sql10
2 files changed, 14 insertions, 6 deletions
diff --git a/sql/schema.sql b/sql/schema.sql
index 06f4091..099e79e 100644
--- a/sql/schema.sql
+++ b/sql/schema.sql
@@ -1,5 +1,5 @@
CREATE TABLE courses (
- id INTEGER PRIMARY KEY,
+ id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
nmax INTEGER NOT NULL,
title TEXT,
ctype TEXT,
@@ -14,3 +14,11 @@ CREATE TABLE users (
session TEXT,
expr INTEGER
);
+CREATE TABLE choices (
+ id INTEGER GENERATED ALWAYS AS IDENTITY,
+ seltime BIGINT NOT NULL, -- microseconds
+ userid TEXT NOT NULL,
+ courseid INTEGER NOT NULL,
+ FOREIGN KEY(userid) REFERENCES users(id),
+ FOREIGN KEY(courseid) REFERENCES courses(id)
+);
diff --git a/sql/tcourse.sql b/sql/tcourse.sql
index afe2aab..bc7b2e7 100644
--- a/sql/tcourse.sql
+++ b/sql/tcourse.sql
@@ -1,5 +1,5 @@
-INSERT INTO courses (id, title, ctype, teacher, location, nmax) VALUES(1, 'Floorball', 'Sport', 'Chen Xiaojia', 'Gym', 20);
-INSERT INTO courses (id, title, ctype, teacher, location, nmax) VALUES(2, 'Flag Football', 'Sport', 'Ding Zhaoyuan', 'Pitch', 30);
-INSERT INTO courses (id, title, ctype, teacher, location, nmax) VALUES(3, 'Chamber Music', 'Enrichment', '(?)', 'Music Rooms', 10);
-INSERT INTO courses (id, title, ctype, teacher, location, nmax) VALUES(4, 'Math and Computer Science', 'Enrichment', 'Jeff Zhang', '2307', 10);
-INSERT INTO courses (id, title, ctype, teacher, location, nmax) VALUES(5, 'Chinese Drama', 'Culture', 'Monica Chen (?)', 'Black Box (?)', 6);
+INSERT INTO courses (title, ctype, teacher, location, nmax) VALUES('Floorball', 'Sport', 'Chen Xiaojia', 'Gym', 20);
+INSERT INTO courses (title, ctype, teacher, location, nmax) VALUES('Flag Football', 'Sport', 'Ding Zhaoyuan', 'Pitch', 30);
+INSERT INTO courses (title, ctype, teacher, location, nmax) VALUES('Chamber Music', 'Enrichment', '(?)', 'Music Rooms', 10);
+INSERT INTO courses (title, ctype, teacher, location, nmax) VALUES('Math and Computer Science', 'Enrichment', 'Jeff Zhang', '2307', 10);
+INSERT INTO courses (title, ctype, teacher, location, nmax) VALUES('Chinese Drama', 'Culture', 'Monica Chen (?)', 'Black Box (?)', 6);