diff --git a/Documentation/mld/mld graphique.md b/Documentation/mld/mld graphique.md index f24b765..d4f2348 100644 --- a/Documentation/mld/mld graphique.md +++ b/Documentation/mld/mld graphique.md @@ -46,12 +46,12 @@ entity "Utilisateur" as utilisateur { entity "Invite" as invite { #idJoueur : int - idSession : int } entity "Partie" as partie { id : int codeInvitation : string + isStarted: bool #idJeu : int } @@ -84,11 +84,46 @@ entity "Question" as question { question : string } +entity "Action" as action { + id : int + dateAction : date +} + +entity "Jouer" as jouer { + #idAction + #idPartie +} + +entity "ActionPendu" as actionPendu { + #idAction + lettre : char + wordToFind : string + lifeLeft : int +} + +entity "ActionKahoot" as actionKahoot { + #idAction + numReponse: int + tempsReponse: int + #idJoueur +} + +entity "ActionQuiEstCe" as actionQuiEstCe { + #idAction + #idJoueur +} + +actionPendu --> action +actionQuiEstCe --> action +actionQuiEstCe --> joueur +actionKahoot --> action +actionKahoot --> joueur +jouer --> action +jouer --> partie partie --> jeu partie <-- joueur invite --> joueur utilisateur --> joueur -utilisateur --> scientifique scientifique --> thematique scientifique --> difficulte scientifique --> indice diff --git a/Documentation/mld/mld.md b/Documentation/mld/mld.md index 8bcc7f1..d2228f9 100644 --- a/Documentation/mld/mld.md +++ b/Documentation/mld/mld.md @@ -1,11 +1,10 @@ **Jeu(id, nom, nbrParties)** - *id* : clef primaire de la table Jeu -**Scientifique(id, nom, prenom, photo, dateNaissance, descriptif, ratioTrouvee, #idThematique, #idDifficulte, #idSexe)** +**Scientifique(id, nom, prenom, photo, dateNaissance, descriptif, ratioTrouvee, sexe, #idThematique, #idDifficulte)** - *id* : clef primaire de la table Scientifique - *#idThematique* clef étrangère en référence à *id* de la table Thematique - *#idDifficulte* clef étrangère en référence à *id* de la table Difficulté -- *#idSexe* clef étrangère en référence à *id* de la table Sexe **Thematique(id, libelle)** - *id* : clef primaire de la table Thematique @@ -13,23 +12,20 @@ **Difficulté(id, libelle)** - *id* : clef primaire de la table Difficulté -**Sexe(id, libelle)** -- *id* : clef primaire de la table Sexe - -**Joueur(id, pseudo)** +**Joueur(id, pseudo, #idPartie)** - *id* : clef primaire de la table Joueur +- *#idPartie* : clef étrangère en référence à *id* de la table Partie **Utilisateur(#idJoueur, email, motDePasse, pseudo)** - *idJoueur* : clef primaire de la table Joueur - *#idJoueur* : clef étrangère en référence à *id* de la table Joueur -**Invite(#idJoueur, idSession)** +**Invite(#idJoueur)** - *idJoueur* : clef primaire de la table Joueur - *#idJoueur* : clef étrangère en référence à *id* de la table Joueur -**Partie(id, codeInvitation, #idJoueur, #idJeu)** +**Partie(id, codeInvitation, #idJeu)** - *id* : clef primaire de la table Partie -- *#idJoueur* : clef étrangère en référence à *id* de la table Joueur - *#idJeu* : clef étrangère en référence à *id* de la table Jeu **Admin(#id, email, motDePasse)** diff --git a/Documentation/script_bdd.sql b/Documentation/script_bdd.sql index a2d14a5..815185d 100644 --- a/Documentation/script_bdd.sql +++ b/Documentation/script_bdd.sql @@ -1,149 +1,134 @@ -- 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; -- THEMATIQUE CREATE TABLE Thematique( - id SERIAL PRIMARY KEY, - libelle varchar(128) NOT NULL UNIQUE + id SERIAL PRIMARY KEY, + libelle varchar(128) NOT NULL UNIQUE ); -- DIFFICULTE CREATE TABLE Difficulte( - id SERIAL PRIMARY KEY, - libelle varchar(128) NOT NULL UNIQUE + id SERIAL PRIMARY KEY, + libelle varchar(128) NOT NULL UNIQUE ); -- SCIENTIFIQUE CREATE TABLE Scientifique( - id SERIAL PRIMARY KEY, - nom varchar(128) NOT NULL, - prenom varchar(128) NOT NULL, - photo varchar(512) NOT NULL, - dateNaissance date NOT NULL, - descriptif text NOT NULL, - ratioTrouvee numeric(5,4), - sexe char(1) NOT NULL CHECK(sexe IN ('F', 'H')), - idThematique integer REFERENCES Thematique(id), - idDifficulte integer REFERENCES Difficulte(id), + id SERIAL PRIMARY KEY, + nom varchar(128) NOT NULL, + prenom varchar(128) NOT NULL, + photo varchar(512) NOT NULL, + dateNaissance date NOT NULL, + descriptif text NOT NULL, + ratioTrouvee numeric(5,4), + sexe char(1) NOT NULL CHECK(sexe IN ('F', 'H')), + idThematique integer REFERENCES Thematique(id), + idDifficulte integer REFERENCES Difficulte(id) ); -- INDICE CREATE TABLE Indice( - id SERIAL PRIMARY KEY, - libelle varchar(512) NOT NULL UNIQUE, - idScientifique integer REFERENCES Scientifique(id) + id SERIAL PRIMARY KEY, + libelle varchar(512) NOT NULL, + idScientifique integer REFERENCES Scientifique(id) ); -- QUESTION CREATE TABLE Question( - id SERIAL PRIMARY KEY, - question varchar(256) NOT NULL UNIQUE + id SERIAL PRIMARY KEY, + question varchar(256) NOT NULL UNIQUE ); -- REPONSE CREATE TABLE Reponse( - id SERIAL PRIMARY KEY, - reponse varchar(255) NOT NULL, - idQuestion integer REFERENCES Question(id), - idScientifique integer REFERENCES Scientifique(id) + id SERIAL PRIMARY KEY, + reponse varchar(255) NOT NULL, + idQuestion integer REFERENCES Question(id), + idScientifique integer REFERENCES Scientifique(id) ); -- ADMIN CREATE TABLE Admin( - id SERIAL PRIMARY KEY, - email varchar(255) NOT NULL UNIQUE, - password varchar(255) NOT NULL + id SERIAL PRIMARY KEY, + email varchar(255) NOT NULL UNIQUE, + 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(5) NOT NULL UNIQUE, + idJeu integer REFERENCES Jeu(id) +); -- JOUEUR CREATE TABLE Joueur( - id SERIAL PRIMARY KEY, - idPartie integer REFERENCES Partie(id), - pseudo varchar(255) NOT NULL UNIQUE + id SERIAL PRIMARY KEY, + idPartie integer REFERENCES Partie(id), + pseudo varchar(255) NOT NULL UNIQUE ); -- Invite CREATE TABLE Invite( - idJoueur integer PRIMARY KEY REFERENCES Joueur(id), - idSession varchar(255) NOT NULL UNIQUE + idJoueur integer PRIMARY KEY REFERENCES Joueur(id) ); -- Utilisateur CREATE TABLE Utilisateur( - idJoueur integer PRIMARY KEY REFERENCES Joueur(id), - email varchar(255) NOT NULL UNIQUE, - password varchar(255) NOT NULL + idJoueur integer PRIMARY KEY REFERENCES Joueur(id), + email varchar(255) NOT NULL UNIQUE, + password varchar(255) NOT NULL ); -- Decouvrir CREATE TABLE Decouvrir( - idUtilisateur integer REFERENCES Utilisateur(idJoueur), - idScientifique integer REFERENCES Scientifique(id), - PRIMARY KEY (idUtilisateur, idScientifique) -); - - --- 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) + idUtilisateur integer REFERENCES Utilisateur(idJoueur), + idScientifique integer REFERENCES Scientifique(id), + PRIMARY KEY (idUtilisateur, idScientifique) ); @@ -152,11 +137,11 @@ CREATE TABLE Partie( -- 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'), - ('Sophie', 'Germain', '', CURRENT_DATE, 'desc', 0, 2, 2, 'F'); + ('Marie', 'Curie', '', CURRENT_DATE, 'desc', 0.50, 1, 1, 'F'), + ('Albert', 'Einstein', '', CURRENT_DATE, 'desc', 0.7540, 2, 1, 'H'), + ('Sophie', 'Germain', '', CURRENT_DATE, 'desc', 0.1432, 2, 2, 'F'); -- Jeu INSERT INTO Jeu(nom) VALUES ('Qui-est-ce ?'),('Science Quizz'), ('Pendu'); @@ -168,6 +153,11 @@ VALUES ('Quel mathématicien a dit : « Dieu existe, c’est les mathématiques » ?'), ('Quel mathématicienne utilisa comme nom d"emprunt « Antoine Auguste Le Blanc » ?'); +-- Indices +INSERT INTO Indice (libelle, idscientifique) VALUES + ('Indice pour aider', 1), + ('S''appelle Marie', 1); + -- Réponses INSERT INTO Reponse(reponse, idQuestion, idScientifique) VALUES @@ -176,11 +166,16 @@ VALUES ('Sophie Germain', 3, 3); -- Utilisateurs -INSERT INTO Joueur(id,pseudo) VALUES (1337, 'moi, le meilleur joueur du monde'); -INSERT INTO Utilisateur(idJoueur,email,password) VALUES (1337, 'joueur','$2y$10$juGnlWC9cS19popEKLZsYeir0Jl39k6hDl0dpaCix00FDcdiEbtmS'); +INSERT INTO Joueur(pseudo) VALUES ('moi, le meilleur joueur du monde'); --id = 1 +INSERT INTO Utilisateur(idJoueur,email,password) VALUES (1, 'joueur','$2y$10$juGnlWC9cS19popEKLZsYeir0Jl39k6hDl0dpaCix00FDcdiEbtmS'); -- mdp = test -INSERT INTO decouvrir(idUtilisateur,idScientifique) VALUES (1337,1); +-- Découvrir +INSERT INTO decouvrir(idUtilisateur,idScientifique) VALUES (1,1); +-- Admin INSERT INTO Admin(id,email,password) VALUES (1, 'admin','$2y$10$juGnlWC9cS19popEKLZsYeir0Jl39k6hDl0dpaCix00FDcdiEbtmS'); -- mdp = test + +-- Partie +INSERT INTO Partie(codeInvitation, idJeu) VALUES ('abcde', 1); \ No newline at end of file