-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbdd.sql
40 lines (34 loc) · 1.12 KB
/
bdd.sql
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
CREATE TABLE users (
ID SERIAL PRIMARY KEY,
nom VARCHAR NOT NULL,
prenom VARCHAR NOT NULL,
pseudo VARCHAR NOT NULL UNIQUE,
email VARCHAR NOT NULL CHECK (([a-zA-Z0-9_\-]+\.)?)+[a-zA-Z0-9_\-]+@([a-zA-Z0-9_\-]+\.[a-z]{2,4}) UNIQUE,
password VARCHAR NOT NULL,
inscriptionDate TIMESTAMP NOT NULL,
permission INT NOT NULL
);
CREATE TABLE categories(
ID SERIAL PRIMARY KEY,
Nom VARCHAR NOT NULL,
image VARCHAR NOT NULL
);
CREATE TABLE articles(
ID SERIAL PRIMARY KEY,
writer_id INT NOT NULL REFERENCES users(ID),
text TEXT NOT NULL,
title VARCHAR NOT NULL,
publish_date TIMESTAMP NOT NULL,
image VARCHAR NOT NULL
);
CREATE TABLE comments(
ID SERIAL PRIMARY KEY,
writer_id INT NOT NULL REFERENCES users(ID) ON DELETE cascade,
text TEXT NOT NULL,
publish_date TIMESTAMP NOT NULL,
article_id INT REFERENCES articles(ID) ON DELETE cascade
);
CREATE TABLE category (
article_id INT NOT NULL REFERENCES articles(ID) ON DELETE cascade,
categories INT NOT NULL REFERENCES categories(ID) ON DELETE cascade,
)