-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
47 lines (42 loc) · 1.02 KB
/
schema.sql
File metadata and controls
47 lines (42 loc) · 1.02 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
CREATE TABLE Users (
id serial PRIMARY KEY,
username varchar(255) UNIQUE,
password varchar(128),
admin boolean,
created_at timestamp DEFAULT CURRENT_TIMESTAMP,
full_name varchar(50),
sport varchar(50),
team varchar(50),
poll_updated_at date,
test_data_added boolean DEFAULT false
);
CREATE TABLE Questions (
question_id serial PRIMARY KEY,
question_text text,
question_type varchar,
radio_low text,
radio_high text,
radio_scale integer,
question_title text UNIQUE,
category varchar
);
CREATE TABLE Data (
entry_id serial PRIMARY KEY,
user_id integer REFERENCES Users (id),
question_id integer REFERENCES Questions (question_id),
response integer,
created_at timestamp DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE Tips (
tip_id serial PRIMARY KEY,
tip_text text,
category varchar
);
CREATE TABLE UserTips (
user_id integer REFERENCES Users (id),
tip_id integer REFERENCES Tips (tip_id),
last_shown timestamp,
shown_count integer DEFAULT 0,
PRIMARY KEY (user_id, tip_id)
);
SELECT 1;