This repository has been archived on 2021-09-15. You can view files and clone it, but cannot push or open issues or pull requests.
ModuleWeb/SRC/init/table.sql

167 lines
3.8 KiB
MySQL
Raw Normal View History

2015-02-15 04:35:26 +00:00
DROP TABLE IF EXISTS password_resets;
2015-02-12 18:19:25 +00:00
DROP TABLE IF EXISTS description;
2015-02-14 22:21:24 +00:00
DROP TABLE IF EXISTS assolisteaoeuvre;
DROP TABLE IF EXISTS assolisteajeu;
2015-02-12 14:08:31 +00:00
DROP TABLE IF EXISTS listeoeuvre;
2015-02-14 22:21:24 +00:00
DROP TABLE IF EXISTS assodesignationaoeuvre;
DROP TABLE IF EXISTS assoauteuraoeuvre;
DROP TABLE IF EXISTS assodatationaoeuvre;
2015-02-12 14:08:31 +00:00
DROP TABLE IF EXISTS oeuvre;
DROP TABLE IF EXISTS auteur;
DROP TABLE IF EXISTS designation;
DROP TABLE IF EXISTS technique;
DROP TABLE IF EXISTS domaine;
DROP TABLE IF EXISTS matiere;
DROP TABLE IF EXISTS datation;
2015-02-15 04:25:36 +00:00
DROP TABLE IF EXISTS users;
2015-02-12 14:08:31 +00:00
DROP TABLE IF EXISTS niveau;
DROP TABLE IF EXISTS jeu;
2015-02-12 18:19:25 +00:00
2015-02-12 14:08:31 +00:00
CREATE TABLE jeu (
idjeu INT NOT NULL AUTO_INCREMENT,
nom VARCHAR(50),
description VARCHAR(255),
PRIMARY KEY (idjeu)
);
CREATE TABLE niveau (
idniveau INT NOT NULL AUTO_INCREMENT,
idjeu INT NOT NULL,
difficulte INT,
caractéristique VARCHAR(255),
PRIMARY KEY (idniveau),
FOREIGN KEY (idjeu) REFERENCES jeu(idjeu)
);
2015-02-15 04:25:36 +00:00
CREATE TABLE users (
2015-02-15 04:53:59 +00:00
id INT NOT NULL AUTO_INCREMENT,
2015-02-17 19:21:30 +00:00
firstname VARCHAR(50),
lastnanme VARCHAR(50),
city VARCHAR(50),
2015-02-15 04:25:36 +00:00
password VARCHAR(255),
2015-02-12 14:08:31 +00:00
email VARCHAR(50),
image VARCHAR(255),
2015-02-15 05:05:45 +00:00
remember_token VARCHAR(100),
2015-02-15 04:25:36 +00:00
admin INT(1) DEFAULT 0,
2015-02-15 04:53:59 +00:00
PRIMARY KEY (id)
2015-02-12 14:08:31 +00:00
);
CREATE TABLE designation (
2015-02-14 22:21:24 +00:00
nom VARCHAR(255) NOT NULL,
2015-02-12 14:08:31 +00:00
urldesignation VARCHAR(255),
2015-02-14 22:21:24 +00:00
PRIMARY KEY (nom)
2015-02-12 14:08:31 +00:00
);
CREATE TABLE auteur (
2015-02-14 22:21:24 +00:00
nom VARCHAR(50) NOT NULL,
2015-02-12 14:08:31 +00:00
anecdote VARCHAR(255),
2015-02-14 22:21:24 +00:00
PRIMARY KEY (nom)
2015-02-12 14:08:31 +00:00
);
CREATE TABLE technique (
2015-02-14 22:21:24 +00:00
nom VARCHAR(50) NOT NULL,
2015-02-12 14:08:31 +00:00
urltechnique VARCHAR(255),
2015-02-14 22:21:24 +00:00
PRIMARY KEY (nom)
2015-02-12 14:08:31 +00:00
);
CREATE TABLE domaine (
2015-02-14 22:21:24 +00:00
nom VARCHAR(50) NOT NULL,
PRIMARY KEY (nom)
2015-02-12 14:08:31 +00:00
);
CREATE TABLE matiere (
2015-02-14 22:21:24 +00:00
nom VARCHAR(50) NOT NULL,
PRIMARY KEY (nom)
2015-02-12 14:08:31 +00:00
);
CREATE TABLE datation (
2015-02-14 22:21:24 +00:00
iddate INT NOT NULL AUTO_INCREMENT,
debut DATE,
fin DATE,
PRIMARY KEY (iddate)
2015-02-12 14:08:31 +00:00
);
CREATE TABLE oeuvre (
idoeuvre INT NOT NULL AUTO_INCREMENT,
2015-02-14 22:21:24 +00:00
iddate INT NOT NULL,
idtechnique VARCHAR(50),
iddomaine VARCHAR(50),
idmatiere VARCHAR(50),
2015-02-12 14:08:31 +00:00
titre VARCHAR(50),
urlPhoto VARCHAR(255),
PRIMARY KEY (idoeuvre),
2015-02-14 22:21:24 +00:00
FOREIGN KEY (idtechnique) REFERENCES technique(nom),
FOREIGN KEY (iddomaine) REFERENCES domaine(nom),
FOREIGN KEY (idmatiere) REFERENCES matiere(nom),
FOREIGN KEY (iddate) REFERENCES datation(iddate)
2015-02-12 14:08:31 +00:00
);
2015-02-14 22:21:24 +00:00
CREATE TABLE assodesignationaoeuvre (
idoeuvre INT NOT NULL,
idesignation VARCHAR(255),
PRIMARY KEY (idesignation,idoeuvre),
FOREIGN KEY (idesignation) REFERENCES designation(nom),
FOREIGN KEY (idoeuvre) REFERENCES oeuvre(idoeuvre)
);
CREATE TABLE assoauteuraoeuvre (
idoeuvre INT NOT NULL,
idauteur VARCHAR(50),
PRIMARY KEY (idauteur,idoeuvre),
FOREIGN KEY (idauteur) REFERENCES auteur(nom),
FOREIGN KEY (idoeuvre) REFERENCES oeuvre(idoeuvre)
);
2015-02-12 14:08:31 +00:00
CREATE TABLE listeoeuvre (
idlisteoeuvre INT NOT NULL AUTO_INCREMENT,
2015-02-15 04:30:29 +00:00
idusers INT NOT NULL,
2015-02-12 14:08:31 +00:00
nom VARCHAR(50),
etat INT(1) DEFAULT 0,
dateCreation TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (idlisteoeuvre),
2015-02-15 04:53:59 +00:00
FOREIGN KEY (idusers) REFERENCES users(id)
2015-02-12 14:08:31 +00:00
);
2015-02-14 22:21:24 +00:00
CREATE TABLE assolisteaoeuvre (
2015-02-12 14:08:31 +00:00
idlisteoeuvre INT NOT NULL,
idoeuvre INT NOT NULL,
PRIMARY KEY (idlisteoeuvre,idoeuvre),
FOREIGN KEY (idlisteoeuvre) REFERENCES listeoeuvre(idlisteoeuvre),
FOREIGN KEY (idoeuvre) REFERENCES oeuvre(idoeuvre)
);
2015-02-14 22:21:24 +00:00
CREATE TABLE assolisteajeu (
2015-02-12 14:08:31 +00:00
idlisteoeuvre INT NOT NULL,
idjeu INT NOT NULL,
2015-02-12 18:19:25 +00:00
PRIMARY KEY (idlisteoeuvre,idjeu),
2015-02-12 14:08:31 +00:00
FOREIGN KEY (idlisteoeuvre) REFERENCES listeoeuvre(idlisteoeuvre),
FOREIGN KEY (idjeu) REFERENCES jeu(idjeu)
);
CREATE TABLE description (
iddescription INT NOT NULL AUTO_INCREMENT,
idoeuvre INT NOT NULL,
idlisteoeuvre INT NOT NULL,
libelle VARCHAR(255),
PRIMARY KEY (iddescription),
FOREIGN KEY (idoeuvre) REFERENCES oeuvre(idoeuvre),
FOREIGN KEY (idlisteoeuvre) REFERENCES listeoeuvre(idlisteoeuvre)
);
2015-02-15 04:35:26 +00:00
CREATE TABLE password_resets (
2015-02-15 04:39:20 +00:00
token VARCHAR(255),
email VARCHAR(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (token)
);