NDI-2020/sql/createSchema.sql

112 lines
2.9 KiB
MySQL
Raw Normal View History

2020-12-04 01:37:13 +01:00
CREATE DATABASE bddsurf
2020-12-04 02:58:35 +01:00
CREATE TABLE joueur
2020-12-04 01:37:13 +01:00
(
2020-12-04 02:58:35 +01:00
idJoueur INT PRIMARY KEY NOT NULL AUTO_INCREMENT, -- primary key column
2020-12-04 01:37:13 +01:00
estVivant TINYINT,
estImposteur TINYINT
);
2020-12-04 02:58:35 +01:00
CREATE TABLE utilisateur
2020-12-04 01:37:13 +01:00
(
2020-12-04 02:58:35 +01:00
idUtilisateur INT PRIMARY KEY NOT NULL AUTO_INCREMENT, -- primary key column
nomUtilisateur VARCHAR(50),
prenomUtilisateur VARCHAR(50),
mailUtilisateur VARCHAR(50),
pseudoUtilisateur VARCHAR(50),
passwordUtilisateur VARCHAR(50)
2020-12-04 01:37:13 +01:00
);
2020-12-04 02:58:35 +01:00
CREATE TABLE meteoville
2020-12-04 01:37:13 +01:00
(
2020-12-04 02:58:35 +01:00
IdMeteoVille INT PRIMARY KEY NOT NULL AUTO_INCREMENT, -- primary key column
2020-12-04 01:37:13 +01:00
temperatureMeteoVille INT,
ventMeteoVille INT
);
2020-12-04 02:58:35 +01:00
CREATE TABLE meteoSpot
2020-12-04 01:37:13 +01:00
(
2020-12-04 02:58:35 +01:00
idMeteoSpot INT PRIMARY KEY NOT NULL AUTO_INCREMENT, -- primary key column
2020-12-04 01:37:13 +01:00
houleMeteoSpot INT,
mareeMeteoSpot INT,
ventMeteoSpot INT
);
2020-12-04 02:58:35 +01:00
CREATE TABLE produits
2020-12-04 01:37:13 +01:00
(
2020-12-04 02:58:35 +01:00
idProduits INT PRIMARY KEY NOT NULL AUTO_INCREMENT, -- primary key column
2020-12-04 01:37:13 +01:00
estCremeSolaire TINYINT,
estParfum TINYINT,
estCremeHydratante TINYINT,
estMaquillage TINYINT,
estEssence TINYINT,
estCigarette TINYINT,
estEngrais TINYINT,
estPeinture TINYINT,
2020-12-04 02:58:35 +01:00
AutreProduit VARCHAR(50)
2020-12-04 01:37:13 +01:00
);
2020-12-04 02:58:35 +01:00
CREATE TABLE pollution
(
idPollution INT PRIMARY KEY NOT NULL AUTO_INCREMENT, -- primary key column
niveauPollution INT,
descriptionPollution VARCHAR(50)
);
CREATE TABLE ville
2020-12-04 01:37:13 +01:00
(
2020-12-04 02:58:35 +01:00
idVille INT PRIMARY KEY NOT NULL AUTO_INCREMENT, -- primary key column
nomVille VARCHAR(50),
cpVille VARCHAR(50),
2020-12-04 02:37:13 +01:00
meteoVille INT NOT NULL,
CONSTRAINT fk_meteoville
FOREIGN KEY (meteoVille)
2020-12-04 02:58:35 +01:00
REFERENCES meteoville(IdMeteoVille)
2020-12-04 01:37:13 +01:00
);
2020-12-04 02:58:35 +01:00
CREATE TABLE pointage
2020-12-04 01:37:13 +01:00
(
2020-12-04 02:58:35 +01:00
idPointage INT PRIMARY KEY NOT NULL AUTO_INCREMENT, -- primary key column
nbBaigneur INT,
nbPratiquant INT,
nbBateauPeche INT,
nbBateauLoisir INT,
nbBateauVoile INT,
produits INT NOT NULL,
niveauDechet INT,
CONSTRAINT fk_produitsPointage
FOREIGN KEY (produits)
REFERENCES produits(idProduits)
);
CREATE TABLE spot
(
idSpot INT PRIMARY KEY NOT NULL AUTO_INCREMENT, -- primary key column
nomSpot VARCHAR(50),
villeSpot INT NOT NULL,
meteoSpot INT NOT NULL,
pollutionSpot INT NOT NULL,
CONSTRAINT fk_villeSpot
FOREIGN KEY (villeSpot)
REFERENCES ville(idVille),
CONSTRAINT fk_meteoSpot
FOREIGN KEY (meteoSpot)
REFERENCES meteoSpot(idMeteoSpot),
CONSTRAINT fk_pollutionSpot
FOREIGN KEY (pollutionSpot)
REFERENCES pollution(idPollution)
);
CREATE TABLE historique
(
idHistorique INT PRIMARY KEY NOT NULL AUTO_INCREMENT, -- primary key column
2020-12-04 01:37:13 +01:00
utilisateur INT NOT NULL,
spot INT NOT NULL,
2020-12-04 02:37:13 +01:00
pointage INT NOT NULL,
CONSTRAINT fk_user
FOREIGN KEY (utilisateur)
2020-12-04 02:58:35 +01:00
REFERENCES utilisateur(idUtilisateur),
CONSTRAINT fk_spot
FOREIGN KEY (spot)
REFERENCES spot(idSpot),
CONSTRAINT fk_pointage
FOREIGN KEY (pointage)
REFERENCES pointage(idPointage)
2020-12-04 01:37:13 +01:00
);