summaryrefslogtreecommitdiff
path: root/sql/schema.sql
blob: d6c81bf7b7b6fb202ea4a214f145e923e237db72 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
CREATE TABLE courses (
	id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
	nmax INTEGER NOT NULL,
	title TEXT,
	ctype TEXT,
	teacher TEXT,
	location TEXT
);
CREATE TABLE users (
	id TEXT PRIMARY KEY NOT NULL,
	name TEXT,
	email TEXT,
	department TEXT,
	session TEXT,
	expr INTEGER
);
CREATE TABLE choices (
	PRIMARY KEY (userid, courseid),
	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)
);