-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql.txt
More file actions
36 lines (28 loc) · 841 Bytes
/
sql.txt
File metadata and controls
36 lines (28 loc) · 841 Bytes
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
-- when you want to drop tables
DROP TABLE solved_probrems;
DROP TABLE users;
DROP TABLE probrems;
-- dbname: acdeer
CREATE TABLE users (
atcoder_id CHAR(16) PRIMARY KEY,
discord_id NUMERIC(64) UNIQUE NOT NULL,
rating NUMERIC(4) NOT NULL
);
CREATE TABLE probrems (
id CHAR(64) PRIMARY KEY,
name TEXT NOT NULL,
difficulty NUMERIC(4),
is_experimental TINYINT(1),
url TEXT NOT NULL
);
CREATE TABLE solved_probrems (
atcoder_id CHAR(16),
probrem_id CHAR(64),
timestamp DATETIME NOT NULL,
PRIMARY KEY (atcoder_id, probrem_id),
FOREIGN KEY (atcoder_id) REFERENCES users(atcoder_id)
ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (probrem_id) REFERENCES probrems(id)
);
CREATE INDEX idx_discord_id ON users(discord_id);
CREATE INDEX idx_difficulty ON probrems(difficulty);