Skip to content

Commit 0e99121

Browse files
author
Sampath-1984
committed
feat(backend-db): sql schema containing tables and relationships
This commit adds a schema.sql that initialises tables and relationships for managing user data. Closes #39
1 parent c02726c commit 0e99121

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

backend/db/schema.sql

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
CREATE TABLE user_info (
2+
id BIGSERIAL NOT NULL PRIMARY KEY,
3+
name VARCHAR(50) NOT NULL,
4+
age SMALLINT NOT NULL CHECK(age > 0),
5+
year SMALLINT NOT NULL CHECK(year IN (1,2,3,4)),
6+
branch VARCHAR(50) NOT NULL CHECK(branch IN ('CSE','ECE','MECH','SM','BDES')),
7+
bio VARCHAR(500),
8+
image VARCHAR(200),
9+
public_key VARCHAR(500) NOT NULL
10+
);
11+
12+
CREATE TABLE tags_table (
13+
id BIGSERIAL NOT NULL PRIMARY KEY,
14+
name VARCHAR(50) NOT NULL
15+
);
16+
17+
CREATE TABLE tags_user_table (
18+
tag_id BIGINT NOT NULL REFERENCES tags_table(id),
19+
user_id BIGINT NOT NULL REFERENCES user_info(id)
20+
);
21+
22+
CREATE TABLE choices_for_chooser (
23+
chooser_id BIGINT NOT NULL REFERENCES user_info(id),
24+
chosen_id BIGINT REFERENCES user_info(id),
25+
UNIQUE (chooser_id)
26+
);
27+
28+
CREATE TABLE choices_for_chosen (
29+
chosen_id BIGINT NOT NULL REFERENCES user_info(id),
30+
chooser_id BIGINT REFERENCES user_info(id),
31+
UNIQUE (chosen_id)
32+
);

0 commit comments

Comments
 (0)