|
|
|
@ -1,29 +1,17 @@
|
|
|
|
|
-- Testé sous pgsql 15
|
|
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS Reponse;
|
|
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS Question;
|
|
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS Admin;
|
|
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS Partie;
|
|
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS Jeu;
|
|
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS Decouvrir;
|
|
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS Utilisateur;
|
|
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS Invite;
|
|
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS Joueur;
|
|
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS Indice;
|
|
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS Scientifique;
|
|
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS Thematique;
|
|
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS Reponse CASCADE;
|
|
|
|
|
DROP TABLE IF EXISTS Question CASCADE;
|
|
|
|
|
DROP TABLE IF EXISTS Admin CASCADE;
|
|
|
|
|
DROP TABLE IF EXISTS Partie CASCADE;
|
|
|
|
|
DROP TABLE IF EXISTS Jeu CASCADE;
|
|
|
|
|
DROP TABLE IF EXISTS Decouvrir CASCADE;
|
|
|
|
|
DROP TABLE IF EXISTS Utilisateur CASCADE;
|
|
|
|
|
DROP TABLE IF EXISTS Invite CASCADE;
|
|
|
|
|
DROP TABLE IF EXISTS Joueur CASCADE;
|
|
|
|
|
DROP TABLE IF EXISTS Indice CASCADE;
|
|
|
|
|
DROP TABLE IF EXISTS Scientifique CASCADE;
|
|
|
|
|
DROP TABLE IF EXISTS Thematique CASCADE;
|
|
|
|
|
DROP TABLE IF EXISTS Difficulte;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -55,7 +43,7 @@ CREATE TABLE Scientifique(
|
|
|
|
|
ratioTrouvee numeric(5,4),
|
|
|
|
|
sexe char(1) NOT NULL CHECK(sexe IN ('F', 'H')),
|
|
|
|
|
idThematique integer REFERENCES Thematique(id),
|
|
|
|
|
idDifficulte integer REFERENCES Difficulte(id),
|
|
|
|
|
idDifficulte integer REFERENCES Difficulte(id)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -93,6 +81,22 @@ CREATE TABLE Admin(
|
|
|
|
|
password varchar(255) NOT NULL
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
-- Jeu
|
|
|
|
|
|
|
|
|
|
CREATE TABLE Jeu(
|
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
|
nom varchar(128) NOT NULL UNIQUE,
|
|
|
|
|
nbrParties integer NOT NULL DEFAULT 0
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Partie
|
|
|
|
|
|
|
|
|
|
CREATE TABLE Partie(
|
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
|
codeInvitation varchar(10) NOT NULL UNIQUE,
|
|
|
|
|
idJeu integer REFERENCES Jeu(id)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
-- JOUEUR
|
|
|
|
|
|
|
|
|
@ -106,7 +110,7 @@ CREATE TABLE Joueur(
|
|
|
|
|
-- Invite
|
|
|
|
|
|
|
|
|
|
CREATE TABLE Invite(
|
|
|
|
|
idJoueur integer PRIMARY KEY REFERENCES Joueur(id),
|
|
|
|
|
idJoueur integer PRIMARY KEY REFERENCES Joueur(id)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -128,30 +132,12 @@ CREATE TABLE Decouvrir(
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Jeu
|
|
|
|
|
|
|
|
|
|
CREATE TABLE Jeu(
|
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
|
nom varchar(128) NOT NULL UNIQUE,
|
|
|
|
|
nbrParties integer NOT NULL DEFAULT 0
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Partie
|
|
|
|
|
|
|
|
|
|
CREATE TABLE Partie(
|
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
|
codeInvitation varchar(10) NOT NULL UNIQUE,
|
|
|
|
|
idJeu integer REFERENCES Jeu(id)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- INSERTS
|
|
|
|
|
|
|
|
|
|
-- Scientifiques
|
|
|
|
|
INSERT INTO Difficulte(libelle) VALUES ('Facile'),('Intermédiaire'),('Difficile');
|
|
|
|
|
INSERT INTO Thematique(libelle) VALUES ('Nucléaire'),('Mathématiques');
|
|
|
|
|
INSERT INTO Scientifique(nom, prenom, photo, dateNaissance, descriptif, ratioTrouvee, idThematique, idDifficulte, idSexe)
|
|
|
|
|
INSERT INTO Scientifique(nom, prenom, photo, dateNaissance, descriptif, ratioTrouvee, idThematique, idDifficulte, sexe)
|
|
|
|
|
VALUES
|
|
|
|
|
('Marie', 'Curie', '', CURRENT_DATE, 'desc', 0, 1, 1, 'F'),
|
|
|
|
|
('Albert', 'Einstein', '', CURRENT_DATE, 'desc', 0, 2, 1, 'H'),
|
|
|
|
|