81 lines
3.2 KiB
MySQL
81 lines
3.2 KiB
MySQL
|
CREATE TABLE Etudes
|
||
|
(
|
||
|
idEtude INT(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||
|
intitule INT(11)
|
||
|
);
|
||
|
CREATE UNIQUE INDEX uindex_Etudes_idEtude ON Etudes (idEtude);
|
||
|
|
||
|
CREATE TABLE Questions
|
||
|
(
|
||
|
idQuestion INT(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||
|
intitule TEXT NOT NULL,
|
||
|
qualification VARCHAR(255) NOT NULL,
|
||
|
ihmType INT(11) NOT NULL,
|
||
|
idEtude INT(11) NOT NULL,
|
||
|
CONSTRAINT uindex_Question_idEtude FOREIGN KEY (idEtude) REFERENCES Etudes (idEtude)
|
||
|
);
|
||
|
|
||
|
CREATE INDEX index_Question_idEtude ON Questions (idEtude);
|
||
|
CREATE UNIQUE INDEX uindex_Questions_idQuestion ON Questions (idQuestion);
|
||
|
|
||
|
CREATE TABLE Personnes
|
||
|
(
|
||
|
idPersonne INT(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||
|
pseudo VARCHAR(255),
|
||
|
nom VARCHAR(255),
|
||
|
prenom VARCHAR(255)
|
||
|
);
|
||
|
CREATE UNIQUE INDEX uindex_Personnes_idPersonne ON Personnes (idPersonne);
|
||
|
|
||
|
CREATE TABLE ReponsesAttendues
|
||
|
(
|
||
|
idReponseAttendue INT(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||
|
intitule VARCHAR(255) NOT NULL,
|
||
|
idQuestion INT(11) NOT NULL,
|
||
|
CONSTRAINT fk_ReponsesAttendues_idQuestion FOREIGN KEY (idQuestion) REFERENCES Questions (idQuestion)
|
||
|
);
|
||
|
CREATE INDEX index_ReponsesAttendues_idQuestion ON ReponsesAttendues (idQuestion);
|
||
|
CREATE UNIQUE INDEX uindex_ReponsesAttendues_idReponseAttendue ON ReponsesAttendues (idReponseAttendue);
|
||
|
|
||
|
CREATE TABLE ReponsesUtilisateurs
|
||
|
(
|
||
|
idReponseUtilisateur INT(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||
|
intitule VARCHAR(255) NOT NULL,
|
||
|
idQuestion INT(11) NOT NULL,
|
||
|
idUtilisateur INT(11) NOT NULL,
|
||
|
CONSTRAINT fk_ReponsesUtilisateurs FOREIGN KEY (idQuestion) REFERENCES Questions (idQuestion),
|
||
|
CONSTRAINT fk_ReponsesUtilisateurs_idPersonne FOREIGN KEY (idUtilisateur) REFERENCES Personnes (idPersonne)
|
||
|
);
|
||
|
CREATE INDEX index_ReponsesUtilisateurs ON ReponsesUtilisateurs (idQuestion);
|
||
|
CREATE INDEX index_ReponsesUtilisateurs_idPersonne ON ReponsesUtilisateurs (idUtilisateur);
|
||
|
CREATE UNIQUE INDEX uindex_ReponsesUtilisateurs_idReponseUtilisateur ON ReponsesUtilisateurs (idReponseUtilisateur);
|
||
|
|
||
|
CREATE TABLE Categories
|
||
|
(
|
||
|
idCategorie INT(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||
|
intitule INT(11) NOT NULL
|
||
|
);
|
||
|
CREATE UNIQUE INDEX uindex_Catégories_idCatégorie ON Categories (idCategorie);
|
||
|
|
||
|
CREATE TABLE Relations
|
||
|
(
|
||
|
idPersonneA INT(11) NOT NULL,
|
||
|
idPersonneB INT(11) NOT NULL,
|
||
|
idCategorie INT(11),
|
||
|
CONSTRAINT `PRIMARY` PRIMARY KEY (idPersonneA, idPersonneB),
|
||
|
CONSTRAINT fk_Relations_idCategorie FOREIGN KEY (idCategorie) REFERENCES Categories (idCategorie),
|
||
|
CONSTRAINT fk_Relations_idUtilsateurA FOREIGN KEY (idPersonneA) REFERENCES Personnes (idPersonne),
|
||
|
CONSTRAINT fk_Relations_idUtilsateurB FOREIGN KEY (idPersonneB) REFERENCES Personnes (idPersonne)
|
||
|
);
|
||
|
CREATE INDEX index_Relations_idCategorie ON Relations (idCategorie);
|
||
|
CREATE INDEX index_Relations_idUtilsateurB ON Relations (idPersonneB);
|
||
|
|
||
|
CREATE TABLE Etude_Personnes
|
||
|
(
|
||
|
idEtude INT(11) DEFAULT '0' NOT NULL,
|
||
|
idPersonne INT(11) DEFAULT '0' NOT NULL,
|
||
|
CONSTRAINT `PRIMARY` PRIMARY KEY (idEtude, idPersonne),
|
||
|
CONSTRAINT fk_EP_idEtude FOREIGN KEY (idEtude) REFERENCES Etudes (idEtude),
|
||
|
CONSTRAINT fk_EP_idPersonne FOREIGN KEY (idPersonne) REFERENCES Personnes (idPersonne)
|
||
|
);
|
||
|
CREATE INDEX index_EP_idPersonne ON Etude_Personnes (idPersonne);
|