You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
879 B

CREATE TABLE registered_user (
id_user SERIAL PRIMARY KEY,
login VARCHAR(32) NOT NULL,
password CHAR(72) NOT NULL, -- BCrypt
role INT NOT NULL DEFAULT 0
);
CREATE TABLE news (
id_news SERIAL PRIMARY KEY,
publication_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
title VARCHAR(60) NOT NULL,
slug VARCHAR(60) NOT NULL,
content TEXT NOT NULL,
author_id INT NOT NULL,
FOREIGN KEY (author_id) REFERENCES registered_user(id_user)
ON DELETE CASCADE
);
CREATE TABLE comment (
id_comment SERIAL PRIMARY KEY,
news_id INT NOT NULL,
publication_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
content TEXT NOT NULL,
author_id INT NOT NULL,
FOREIGN KEY (news_id) REFERENCES news(id_news)
ON DELETE CASCADE,
FOREIGN KEY (author_id) REFERENCES registered_user(id_user)
ON DELETE CASCADE
);