-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem.sql
More file actions
41 lines (37 loc) · 1.12 KB
/
Copy pathproblem.sql
File metadata and controls
41 lines (37 loc) · 1.12 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
CREATE TABLE problems (
problem_id BIGSERIAL PRIMARY KEY,
title TEXT NOT NULL,
difficulty VARCHAR(20) NOT NULL,
statement TEXT NOT NULL,
input_format TEXT,
output_format TEXT,
examples JSONB,
constraints JSONB,
sample_testcases JSONB,
hidden_testcases JSONB,
topics TEXT [],
hints JSONB,
starter_code JSONB,
daily_problem_id UUID,
contest_id UUID,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE problems
ADD CONSTRAINT fk_daily_problem FOREIGN KEY (daily_problem_id) REFERENCES daily_problems (daily_problem_id);
ALTER TABLE problems
ADD CONSTRAINT fk_contest FOREIGN KEY (contest_id) REFERENCES contests (contest_id);
CREATE TABLE daily_problems (
daily_problem_id UUID PRIMARY KEY,
prompt TEXT NOT NULL,
generated_date DATE NOT NULL UNIQUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE contests (
contest_id UUID PRIMARY KEY,
title TEXT NOT NULL,
is_user_created BOOLEAN NOT NULL DEFAULT FALSE,
user_id BIGINT,
user_requirements JSONB,
prompt JSONB,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);