From 429e2530f7d4f824a6994d89fcc8dbe2a4f5e1a1 Mon Sep 17 00:00:00 2001 From: Ornel_Zply Date: Tue, 28 Oct 2025 11:29:40 +0100 Subject: [PATCH] 28/10 --- .../Machine_applicatif/database/data.sql | 111 ++++++++++++++ .../Machine_applicatif/database/schema.sql | 136 ++++++++++++++++++ 2 files changed, 247 insertions(+) create mode 100644 observabilite_applicatif/Machine_applicatif/database/data.sql create mode 100644 observabilite_applicatif/Machine_applicatif/database/schema.sql diff --git a/observabilite_applicatif/Machine_applicatif/database/data.sql b/observabilite_applicatif/Machine_applicatif/database/data.sql new file mode 100644 index 0000000..3078e49 --- /dev/null +++ b/observabilite_applicatif/Machine_applicatif/database/data.sql @@ -0,0 +1,111 @@ +-- Ajout des rôles +INSERT INTO role (nom) +VALUES ('Administrateur'), + ('Enseignant'), + ('Étudiant'); + +-- Ajout des utilisateurs +INSERT INTO utilisateur (login, mot_de_passe, nom, prenom, email) +VALUES ('jlpicar', 'password', 'Picard', 'Jean-Luc', 'jean-luc.picard@starfleet.com'), + ('kjaneway', 'password', 'Janeway', 'Kathryn', 'kathryn.janeway@starfleet.com'), + ('spock', 'password', '', 'Spock', 'spock@starfleet.com'), + ('wriker', 'password', 'Riker', 'William', 'william.riker@starfleet.com'), + ('data', 'password', '', 'Data', 'data@starfleet.com'), + ('glaforge', 'password', 'LaForge', 'Geordi', 'geordi.laforge@starfleet.com'), + ('tuvok', 'password', 'Tuvok', '', 'tuvok@starfleet.com'), + ('wcrusher', 'password', 'Crusher', 'Wesley', 'wesley.crusher@starfleet.com'), + ('tparis', 'password', 'Paris', 'Tom', 'tom.paris@starfleet.com'), + ('hkim', 'password', 'Kim', 'Harry', 'harry.kim@starfleet.com'), + ('jsisko', 'password', 'Sisko', 'Jake', 'jake.sisko@starfleet.com'), + ('nog', 'password', '', 'Nog', 'nog@starfleet.com'), + ('bmariner', 'password', 'Mariner', 'Beckett', 'beckett.mariner@starfleet.com'), + ('bboimler', 'password', 'Boimler', 'Brad', 'brad.boimler@starfleet.com'), + ('dvtendi', 'password', 'Tendi', 'D''Vana', 'd-vana.tendi@starfleet.com'), + ('srutherf', 'password', 'Rutherford', 'Sam', 'sam.rutherford@starfleet.com'), + ('drel', 'password', 'R''El', 'Dal', 'dal.r-el@starfleet.com'), + ('gwyndala', 'password', '', 'Gwyndala', 'gwyndala@starfleet.com'), + ('roktahk', 'password', '', 'Rok-Tahk', 'rok-takh@starfleet.com'), + ('zero', 'password', 'Zero', '', 'zero@starfleet.com'), + ('jpog', 'password', 'Pog', 'Jankom', 'jankom.pog@starfleet.com'), + ('murf', 'password', '', 'Murf', 'murf@starfleet.com'); + +-- Ajout des rôles aux utilisateurs +INSERT INTO utilisateur_role (utilisateur_id, role_id) +VALUES ((select id from utilisateur where login = 'jlpicar'), 1), -- Picard as Administrator + ((select id from utilisateur where login = 'kjaneway'), 1), -- Janeway as Administrator + ((select id from utilisateur where login = 'spock'), 2), -- Spock as Teacher + ((select id from utilisateur where login = 'wriker'), 2), -- Riker as Teacher + ((select id from utilisateur where login = 'data'), 2), -- Data as Teacher + ((select id from utilisateur where login = 'glaforge'), 2), -- LaForge as Teacher + ((select id from utilisateur where login = 'tuvok'), 2), -- Tuvok as Teacher + ((select id from utilisateur where login = 'wcrusher'), 3), -- Crusher as Student + ((select id from utilisateur where login = 'tparis'), 3), -- Paris as Student + ((select id from utilisateur where login = 'hkim'), 3), -- Kim as Student + ((select id from utilisateur where login = 'jsisko'), 3), -- Sisko as Student + ((select id from utilisateur where login = 'nog'), 3), -- Nog as Student + ((select id from utilisateur where login = 'bmariner'), 3), -- Mariner as Student + ((select id from utilisateur where login = 'bboimler'), 3), -- Boimler as Student + ((select id from utilisateur where login = 'dvtendi'), 3), -- Tendi as Student + ((select id from utilisateur where login = 'srutherf'), 3), -- Rutherford as Student + ((select id from utilisateur where login = 'drel'), 3), -- R'El as Student + ((select id from utilisateur where login = 'gwyndala'), 3), -- Gwyndala as Student + ((select id from utilisateur where login = 'roktahk'), 3), -- Rok-Tahk as Student + ((select id from utilisateur where login = 'zero'), 3), -- Zero as Student + ((select id from utilisateur where login = 'jpog'), 3), -- Pog as Student + ((select id from utilisateur where login = 'murf'), 3); +-- Murf as Student + +-- Ajout des cours +INSERT INTO cours (nom, date_debut) +VALUES ('Starship Command', '2023-01-01'), + ('Warp Theory', '2023-02-01'), + ('Federation Ethics', '2023-03-01'); + +-- Ajout des enseignements +INSERT INTO enseignement (utilisateur_id, cours_id) +VALUES ((select id from utilisateur where login = 'spock'), 1), -- Spock teaches Starship Command + ((select id from utilisateur where login = 'wriker'), 1), -- Riker teaches Starship Command + ((select id from utilisateur where login = 'data'), 2), -- Data teaches Warp Theory + ((select id from utilisateur where login = 'glaforge'), 2), -- LaForge teaches Warp Theory + ((select id from utilisateur where login = 'tuvok'), 3); +-- Tuvok teaches Federation Ethics + +-- Ajout des inscriptions +INSERT INTO inscription (utilisateur_id, cours_id) +VALUES ((select id from utilisateur where login = 'wcrusher'), 1), -- Crusher enrolls in Starship Command + ((select id from utilisateur where login = 'wcrusher'), 2), -- Crusher enrolls in Warp Theory + ((select id from utilisateur where login = 'tparis'), 1), -- Paris enrolls in Starship Command + ((select id from utilisateur where login = 'hkim'), 1), -- Kim enrolls in Starship Command + ((select id from utilisateur where login = 'jsisko'), 3), -- Sisko enrolls in Federation Ethics + ((select id from utilisateur where login = 'nog'), 1), -- Nog enrolls in Starship Command + ((select id from utilisateur where login = 'nog'), 3), -- Nog enrolls in Federation Ethics + ((select id from utilisateur where login = 'bboimler'), 1), -- Boimler enrolls in Starship Command + ((select id from utilisateur where login = 'dvtendi'), 2), -- Tendi enrolls in Warp Theory + ((select id from utilisateur where login = 'srutherf'), 2), -- Rutherford enrolls in Warp Theory + ((select id from utilisateur where login = 'drel'), 1), -- R'El enrolls in Starship Command + ((select id from utilisateur where login = 'gwyndala'), 1), -- Gwyndala enrolls in Starship Command + ((select id from utilisateur where login = 'gwyndala'), 3), -- Gwyndala enrolls in Federation Ethics + ((select id from utilisateur where login = 'roktahk'), 2), -- Rok-Tahk enrolls in Warp Theory + ((select id from utilisateur where login = 'zero'), 3), -- Zero enrolls in Federation Ethics + ((select id from utilisateur where login = 'jpog'), 2); +-- Pog enrolls in Warp Theory + +-- Ajout des contenus de cours +INSERT INTO contenu_cours (cours_id, titre, description) +VALUES (1, 'Bridge Operations', 'Learn how to manage starship operations.'), + (1, 'Tactical Maneuvers', 'Advanced starship tactics.'), + (1, 'Command Decision Making', 'Develop leadership skills for commanding a starship.'), + (2, 'Warp Core Mechanics', 'Understand the inner workings of warp cores.'), + (2, 'Dilithium Crystals', 'Study the properties of dilithium crystals.'), + (2, 'Warp Field Theory', 'Explore the physics behind warp travel.'), + (3, 'Prime Directive', 'Ethical dilemmas in space exploration.'), + (3, 'Cultural Sensitivity', 'Learn how to interact with alien civilizations.'), + (3, 'Federation Law', 'Understand the legal framework of the Federation.'); + +-- Ajout des devoirs +INSERT INTO devoir (cours_id, titre, description, date_debut, date_fin) +VALUES (1, 'Bridge Simulation', 'Participate in a simulated bridge operation.', '2023-01-15', '2023-01-30'), + (1, 'Tactical Exercise', 'Plan and execute tactical maneuvers.', '2023-01-20', '2023-02-05'), + (2, 'Warp Core Analysis', 'Analyze the efficiency of a warp core.', '2023-02-10', '2023-02-25'), + (2, 'Crystal Experiment', 'Experiment with dilithium crystals.', '2023-02-15', '2023-03-01'), + (3, 'Prime Directive Case Study', 'Discuss ethical dilemmas.', '2023-03-10', '2023-03-25'); diff --git a/observabilite_applicatif/Machine_applicatif/database/schema.sql b/observabilite_applicatif/Machine_applicatif/database/schema.sql new file mode 100644 index 0000000..cba3155 --- /dev/null +++ b/observabilite_applicatif/Machine_applicatif/database/schema.sql @@ -0,0 +1,136 @@ +-- Drop tables if they exist +DROP TABLE IF EXISTS note; +DROP TABLE IF EXISTS rendu_devoir; +DROP TABLE IF EXISTS devoir; +DROP TABLE IF EXISTS contenu_cours; +DROP TABLE IF EXISTS inscription; +DROP TABLE IF EXISTS enseignement; +DROP TABLE IF EXISTS cours; +DROP TABLE IF EXISTS utilisateur_role; +DROP TABLE IF EXISTS role; +DROP TABLE IF EXISTS utilisateur; + +-- Table utilisateur : représente un utilisateur de l'application +CREATE TABLE utilisateur +( + id BIGSERIAL NOT NULL, + login VARCHAR(8) NOT NULL, + mot_de_passe VARCHAR(255) NOT NULL, + nom VARCHAR(100), + prenom VARCHAR(100), + email VARCHAR(255), + PRIMARY KEY (id), + CONSTRAINT ux_u_login UNIQUE (login), + CONSTRAINT ux_u_email UNIQUE (email) +); +CREATE INDEX ix_u_login ON utilisateur (login); + +-- Table role : représente un rôle d'utilisateur +CREATE TABLE role +( + id BIGSERIAL NOT NULL, + nom VARCHAR(100) NOT NULL, + PRIMARY KEY (id), + CONSTRAINT ux_r_nom UNIQUE (nom) +); +CREATE INDEX ix_r_nom ON role (nom); + +-- Table utilisateur_role : association entre utilisateurs et rôles +CREATE TABLE utilisateur_role +( + utilisateur_id BIGINT NOT NULL, + role_id BIGINT NOT NULL, + PRIMARY KEY (utilisateur_id, role_id), + CONSTRAINT fk_ur_utilisateur_id FOREIGN KEY (utilisateur_id) REFERENCES utilisateur (id) ON DELETE CASCADE, + CONSTRAINT fk_ur_role_id FOREIGN KEY (role_id) REFERENCES role (id) ON DELETE CASCADE +); +CREATE INDEX ix_ur_utilisateur_id ON utilisateur_role (utilisateur_id); +CREATE INDEX ix_ur_role_id ON utilisateur_role (role_id); + +-- Table cours : représente un cours +CREATE TABLE cours +( + id BIGSERIAL NOT NULL, + nom VARCHAR(100) NOT NULL, + date_debut DATE NOT NULL, + PRIMARY KEY (id) +); +CREATE INDEX ix_c_nom ON cours (nom); + +-- Table enseignement : association entre utilisateurs et cours +CREATE TABLE enseignement +( + utilisateur_id BIGINT NOT NULL, + cours_id BIGINT NOT NULL, + PRIMARY KEY (utilisateur_id, cours_id), + CONSTRAINT fk_e_utilisateur_id FOREIGN KEY (utilisateur_id) REFERENCES utilisateur (id) ON DELETE CASCADE, + CONSTRAINT fk_e_cours_id FOREIGN KEY (cours_id) REFERENCES cours (id) ON DELETE CASCADE +); +CREATE INDEX ix_e_utilisateur_id ON enseignement (utilisateur_id); +CREATE INDEX ix_e_cours_id ON enseignement (cours_id); + +-- Table inscription : association entre utilisateurs et cours +CREATE TABLE inscription +( + utilisateur_id BIGINT NOT NULL, + cours_id BIGINT NOT NULL, + date_inscription TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (utilisateur_id, cours_id), + CONSTRAINT fk_i_utilisateur_id FOREIGN KEY (utilisateur_id) REFERENCES utilisateur (id) ON DELETE CASCADE, + CONSTRAINT fk_i_cours_id FOREIGN KEY (cours_id) REFERENCES cours (id) ON DELETE CASCADE +); +CREATE INDEX ix_i_utilisateur_id ON inscription (utilisateur_id); +CREATE INDEX ix_i_cours_id ON inscription (cours_id); + +-- Table contenu_cours : représente le contenu d'un cours +CREATE TABLE contenu_cours +( + id BIGSERIAL NOT NULL, + cours_id BIGINT NOT NULL, + titre VARCHAR(255) NOT NULL, + description TEXT, + PRIMARY KEY (id), + CONSTRAINT fk_cc_cours_id FOREIGN KEY (cours_id) REFERENCES cours (id) ON DELETE CASCADE +); +CREATE INDEX ix_cc_cours_id ON contenu_cours (cours_id); + +-- Table devoir : représente un devoir associé à un cours +CREATE TABLE devoir +( + id BIGSERIAL NOT NULL, + cours_id BIGINT NOT NULL, + titre VARCHAR(255) NOT NULL, + description TEXT, + date_debut TIMESTAMP NOT NULL, + date_fin TIMESTAMP NOT NULL, + PRIMARY KEY (id), + CONSTRAINT fk_d_cours_id FOREIGN KEY (cours_id) REFERENCES cours (id) ON DELETE CASCADE +); +CREATE INDEX ix_d_cours_id ON devoir (cours_id); + +-- Table rendu_devoir : représente le rendu d'un devoir par un utilisateur +CREATE TABLE rendu_devoir +( + id BIGSERIAL NOT NULL, + devoir_id BIGINT NOT NULL, + utilisateur_id BIGINT NOT NULL, + date_rendu TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + contenu TEXT, + PRIMARY KEY (id), + CONSTRAINT fk_rd_devoir_id FOREIGN KEY (devoir_id) REFERENCES devoir (id) ON DELETE CASCADE, + CONSTRAINT fk_rd_utilisateur_id FOREIGN KEY (utilisateur_id) REFERENCES utilisateur (id) ON DELETE CASCADE +); +CREATE INDEX ix_rd_devoir_id ON rendu_devoir (devoir_id); +CREATE INDEX ix_rd_utilisateur_id ON rendu_devoir (utilisateur_id); + +-- Table note : représente une note attribuée à un rendu de devoir +CREATE TABLE note +( + id BIGSERIAL NOT NULL, + rendu_devoir_id BIGINT NOT NULL, + valeur DECIMAL(5, 2) NOT NULL CHECK (valeur >= 0 AND valeur <= 20), + date_attribution TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (id), + CONSTRAINT fk_n_rendu_devoir_id FOREIGN KEY (rendu_devoir_id) REFERENCES rendu_devoir (id) ON DELETE CASCADE +); +CREATE INDEX ix_n_rendu_devoir_id ON note (rendu_devoir_id); \ No newline at end of file