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.

61 lines
1.9 KiB

CREATE TABLE User (
id_user numeric PRIMARY KEY,
username varchar(50) NOT NULL,
email varchar(50) NOT NULL,
phone varchar(10) NOT NULL,
pssword varchar(99)NOT NULL,
creation date NOT NULL,
CONSTRAINT uniq_fields UNIQUE (username, email, phone)
);
CREATE TABLE Commentary (
id_comment numeric PRIMARY KEY,
comment text NOT NULL,
user numeric REFERENCES User(id_user),
quote numeric REFERENCES Quote(id_quote)
);
CREATE TABLE Quote (
id_quote numeric PRIMARY KEY,
content text NOT NULL UNIQUE,
img_path varchar(50) NOT NULL,
likes numeric NOT NULL DEFAULT 0,
time_code varchar(10) NOT NULL,
langue varchar(50) NOT NULL,
is_valid boolean NOT NULL DEFAULT true,
reason text,
support numeric REFERENCES Support(id_support),
user numeric REFERENCES User(id_user)
);
CREATE TABLE Support (
id_support numeric PRIMARY KEY,
title varchar(50) NOT NULL,
form varchar(30) NOT NULL,
release date NOT NULL,
CONSTRAINT type_form CHECK (form IN ('Movie', 'Video-Game', 'Novel', 'Anime'))
);
CREATE TABLE Favorite (
id_fav numeric PRIMARY KEY,
user numeric REFERENCES User(id_user),
quote numeric REFERENCES Quote(id_quote)
);
CREATE TABLE Quiz (
id_quiz numeric PRIMARY KEY,
lvl numeric NOT NULL,
duration numeric NOT NULL
);
CREATE TABLE Question (
id_question numeric PRIMARY KEY,
question varchar(99) NOT NULL,
answerA varchar(99) NOT NULL,
answerB varchar(99) NOT NULL,
answerC varchar(99) NOT NULL,
answerD varchar(99) NOT NULL,
cAnswer varchar(99) NOT NULL,
quiz numeric REFERENCES Quiz(id_quiz)
);