-
-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathschema.sql
More file actions
28 lines (25 loc) · 708 Bytes
/
schema.sql
File metadata and controls
28 lines (25 loc) · 708 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
CREATE TABLE users (
id SERIAL PRIMARY KEY,
username VARCHAR NOT NULL,
password_salt BYTEA NOT NULL,
password_scrypt BYTEA NOT NULL,
UNIQUE(username)
);
CREATE TABLE blooms (
id BIGSERIAL NOT NULL PRIMARY KEY,
sender_id INT NOT NULL REFERENCES users(id),
content VARCHAR(280) NOT NULL,
send_timestamp TIMESTAMP NOT NULL
);
CREATE TABLE follows (
id SERIAL PRIMARY KEY,
follower INT NOT NULL REFERENCES users(id),
followee INT NOT NULL REFERENCES users(id),
UNIQUE(follower, followee)
);
CREATE TABLE hashtags (
id SERIAL PRIMARY KEY,
hashtag VARCHAR NOT NULL,
bloom_id BIGINT NOT NULL REFERENCES blooms(id),
UNIQUE(hashtag, bloom_id)
);