-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbdd.sql
38 lines (35 loc) · 971 Bytes
/
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
CREATE TABLE post (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
slug VARCHAR(255) NOT NULL,
content TEXT(650000) NOT NULL,
created_at DATETIME NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE category (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
slug VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE post_category (
post_id INT UNSIGNED NOT NULL,
category_id INT UNSIGNED NOT NULL,
PRIMARY KEY (post_id, category_id),
CONSTRAINT fk_post
FOREIGN KEY (post_id)
REFERENCES post (id)
ON DELETE CASCADE
ON UPDATE RESTRICT,
CONSTRAINT fk_category
FOREIGN KEY (category_id)
REFERENCES category (id)
ON DELETE CASCADE
ON UPDATE RESTRICT
);
CREATE TABLE user (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
username VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
);