-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdatabase.sql
More file actions
51 lines (42 loc) · 1.34 KB
/
database.sql
File metadata and controls
51 lines (42 loc) · 1.34 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
-- CREATE DATABASE lbag;
CREATE TABLE users (
user_id SERIAL PRIMARY KEY,
username VARCHAR NOT NULL UNIQUE,
email VARCHAR NOT NULL UNIQUE,
password VARCHAR,
date_registered TIMESTAMP NOT NULL default now(),
origin VARCHAR NOT NULL
);
CREATE INDEX "users_origin" ON "users" ("origin");
CREATE TABLE projects (
project_id SERIAL PRIMARY KEY,
name VARCHAR NOT NULL UNIQUE
);
CREATE TABLE user_projects (
project_id INTEGER NOT NULL REFERENCES projects,
user_id INTEGER NOT NULL REFERENCES users,
is_subscribed BOOLEAN NOT NULL,
PRIMARY KEY (project_id, user_id)
);
CREATE TABLE notifications (
notification_id SERIAL PRIMARY KEY,
notification_desc VARCHAR(50) NOT NULL
);
CREATE TABLE user_notifications (
user_id INTEGER NOT NULL REFERENCES users,
notification_id INTEGER NOT NULL REFERENCES notifications,
PRIMARY KEY (user_id, notification_id)
);
CREATE TABLE newsletter (
user_id INTEGER REFERENCES users (user_id),
frequency INTEGER NOT NULL
);
CREATE TABLE email_verification (
user_id SERIAL PRIMARY KEY,
email VARCHAR NOT NULL UNIQUE,
code VARCHAR NOT NULL UNIQUE
);
CREATE TABLE settings (
user_id INTEGER PRIMARY KEY REFERENCES users (user_id),
notifications_frequency VARCHAR
);