forked from dachan/dach
1
0
Fork 0

created postgresql schematic

This commit is contained in:
leca 2023-10-24 15:03:00 +03:00
parent 57e24a39ac
commit 0e77772f63
1 changed files with 46 additions and 0 deletions

46
database_schematic.pgsql Normal file
View File

@ -0,0 +1,46 @@
CREATE TABLE boards (
board_id VARCHAR(5) PRIMARY KEY,
board_name VARCHAR(32) NOT NULL,
threads_ids INT8[]
);
CREATE TABLE threads (
thread_id SERIAL8 PRIMARY KEY,
thread_name VARCHAR(32),
root_post_id INT NOT NULL,
posts_ids INT[]
);
CREATE TABLE media (
media_id VARCHAR(22) PRIMARY KEY -- format: ${thread_id}-${media_number}, len(thread_id) = 20, + "-" + len(media_number) = 1 = 22
);
CREATE TABLE posts (
post_id SERIAL8 PRIMARY KEY,
content TEXT NOT NULL,
media_ids VARCHAR(22)[],
is_root BOOL NOT NULL,
date DATE NOT NULL,
internal_id INT NOT NULL, -- id of the post inside of the thread
user_ip CIDR NOT NULL
);
CREATE TABLE admins (
login VARCHAR(16) PRIMARY KEY,
password_hash CHAR(60) NOT NULL,
privelege_name VARCHAR(16) NOT NULL
);
CREATE TABLE priveleges (
privelege_name VARCHAR(16) PRIMARY KEY,
access_level INT2 NOT NULL
);
CREATE TABLE bans (
ban_id SERIAL8 PRIMARY KEY,
user_ip CIDR NOT NULL,
duration INT8, -- duration in seconds
reason VARCHAR(255),
date DATE NOT NULL,
admin_issued VARCHAR(16) NOT NULL
);