-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path00-structure.sql
More file actions
40 lines (36 loc) · 1.1 KB
/
00-structure.sql
File metadata and controls
40 lines (36 loc) · 1.1 KB
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
CREATE TABLE referentiel
(
id int AUTO_INCREMENT
PRIMARY KEY,
titre varchar(100) NOT NULL,
description varchar(255) NULL,
url varchar(1000) NOT NULL,
createur varchar(255) NOT NULL,
date_creation datetime DEFAULT CURRENT_TIMESTAMP NOT NULL
)
COMMENT 'Ensemble des ressources du référentiel';
CREATE INDEX referentiel_titre_index
ON referentiel (titre);
CREATE TABLE tag
(
id int AUTO_INCREMENT
PRIMARY KEY,
code varchar(100) NOT NULL,
nom varchar(200) NOT NULL,
CONSTRAINT tag_unique_code
UNIQUE (code),
CONSTRAINT tag_unique_nom
UNIQUE (nom)
)
COMMENT 'Sujets (ou tags) des ressources du référentiel';
CREATE TABLE referentiel_tag
(
id_referentiel int NOT NULL,
id_tag int NOT NULL,
PRIMARY KEY (id_referentiel, id_tag),
CONSTRAINT referentiel_tag_referentiel_id_fk
FOREIGN KEY (id_referentiel) REFERENCES referentiel (id),
CONSTRAINT referentiel_tag_tag_id_fk
FOREIGN KEY (id_tag) REFERENCES tag (id)
)
COMMENT 'Table d''association entre les ressources du référentiel et les sujets';