-- phpMyAdmin SQL Dump
-- version 5.2.0
-- https://www.phpmyadmin.net/
--
-- Hôte : 127.0.0.1
-- Généré le : sam. 29 août 2026 à 16:53
-- Version du serveur : 10.4.27-MariaDB
-- Version de PHP : 8.2.0

SET FOREIGN_KEY_CHECKS=0;
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Base de données : `est`
--

-- --------------------------------------------------------

--
-- Structure de la table `admin`
--

CREATE TABLE `admin` (
                         `id` bigint(20) NOT NULL,
                         `email` varchar(255) NOT NULL,
                         `password` varchar(255) DEFAULT NULL,
                         `nom` varchar(50) DEFAULT NULL,
                         `cin` varchar(50) DEFAULT NULL,
                         `phone` varchar(50) DEFAULT NULL,
                         `prenom` varchar(255) NOT NULL,
                         `blocked` int(11) NOT NULL,
                         `cnx_fail_number` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `affectation_module`
--

CREATE TABLE `affectation_module` (
                                      `id` bigint(20) NOT NULL,
                                      `module_id` bigint(20) NOT NULL,
                                      `filiere_id` bigint(20) NOT NULL,
                                      `semestre_id` bigint(20) NOT NULL,
                                      `employee_id` bigint(20) NOT NULL,
                                      `annee_universitaire_id` bigint(20) DEFAULT NULL,
                                      `nb_etudiants` int(11) NOT NULL,
                                      `description` text NOT NULL,
                                      `nbr_heure_cours` int(11) DEFAULT NULL,
                                      `nbr_heure_tp` int(11) DEFAULT NULL,
                                      `nbr_heure_td` int(11) DEFAULT NULL,
                                      `nbr_heure_total` int(11) DEFAULT NULL,
                                      `nbr_heure_realise_cours` int(11) DEFAULT NULL,
                                      `nbr_heure_realise_tp` int(11) DEFAULT NULL,
                                      `nbr_heure_realise_td` int(11) DEFAULT NULL,
                                      `nbr_heure_realise_total` int(11) DEFAULT NULL,
                                      `created_at` datetime DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `affectation_module_detail`
--

CREATE TABLE `affectation_module_detail` (
                                             `id` bigint(20) NOT NULL,
                                             `affectation_module_id` bigint(20) NOT NULL,
                                             `student_id` bigint(20) NOT NULL,
                                             `description` varchar(255) DEFAULT NULL,
                                             `created_at` datetime DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `annee_budgitaire`
--

CREATE TABLE `annee_budgitaire` (
                                    `id` bigint(20) NOT NULL,
                                    `libelle` varchar(255) NOT NULL,
                                    `code` varchar(50) NOT NULL,
                                    `style` varchar(50) DEFAULT NULL,
                                    `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `annee_universitaire`
--

CREATE TABLE `annee_universitaire` (
                                       `id` bigint(20) NOT NULL,
                                       `code` varchar(50) NOT NULL,
                                       `libelle` varchar(255) NOT NULL,
                                       `description` text DEFAULT NULL,
                                       `date_creation` date DEFAULT NULL,
                                       `date_modification` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `avancement`
--

CREATE TABLE `avancement` (
                              `id` int(11) NOT NULL,
                              `libelle` varchar(255) NOT NULL,
                              `description` text DEFAULT NULL,
                              `employee_id` bigint(20) DEFAULT NULL,
                              `etat_avancement_id` bigint(20) NOT NULL,
                              `echellon_source_id` bigint(20) NOT NULL,
                              `echellon_destination_id` bigint(20) NOT NULL,
                              `avancement_type_id` bigint(20) NOT NULL,
                              `date_demande` date DEFAULT NULL,
                              `date_avancement` date DEFAULT NULL,
                              `date_decision` date DEFAULT NULL,
                              `date_creation` date NOT NULL DEFAULT current_timestamp(),
                              `date_modification` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `avancement_type`
--

CREATE TABLE `avancement_type` (
                                   `id` bigint(20) NOT NULL,
                                   `libelle` varchar(255) NOT NULL,
                                   `code` varchar(100) NOT NULL,
                                   `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `budget_faculte`
--

CREATE TABLE `budget_faculte` (
                                  `id` bigint(20) NOT NULL,
                                  `libelle` varchar(255) NOT NULL,
                                  `description` text DEFAULT NULL,
                                  `annee_budgitaire_id` bigint(20) NOT NULL,
                                  `montant_investissement_total` decimal(15,2) NOT NULL DEFAULT 0.00,
                                  `montant_fonctionnement_total` decimal(15,2) NOT NULL DEFAULT 0.00,
                                  `montant_investissement_engage` decimal(15,2) NOT NULL DEFAULT 0.00,
                                  `montant_fonctionnement_engage` decimal(15,2) NOT NULL DEFAULT 0.00,
                                  `montant_investissement_paye` decimal(15,2) NOT NULL DEFAULT 0.00,
                                  `montant_fonctionnement_paye` decimal(15,2) NOT NULL DEFAULT 0.00,
                                  `montant_investissement_restant` decimal(15,2) NOT NULL DEFAULT 0.00,
                                  `montant_fonctionnement_restant` decimal(15,2) NOT NULL DEFAULT 0.00,
                                  `etat_budget_faculte_id` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `budget_faculte_detail`
--

CREATE TABLE `budget_faculte_detail` (
                                         `id` bigint(20) NOT NULL,
                                         `pourcentage` decimal(5,2) NOT NULL DEFAULT 0.00,
                                         `libelle` varchar(255) NOT NULL,
                                         `description` text DEFAULT NULL,
                                         `budget_faculte_id` bigint(20) NOT NULL,
                                         `entite_administrative_id` bigint(20) NOT NULL,
                                         `montant_investissement_total` decimal(15,2) NOT NULL DEFAULT 0.00,
                                         `montant_fonctionnement_total` decimal(15,2) NOT NULL DEFAULT 0.00,
                                         `montant_investissement_engage` decimal(15,2) NOT NULL DEFAULT 0.00,
                                         `montant_fonctionnement_engage` decimal(15,2) NOT NULL DEFAULT 0.00,
                                         `montant_investissement_paye` decimal(15,2) NOT NULL DEFAULT 0.00,
                                         `montant_fonctionnement_paye` decimal(15,2) NOT NULL DEFAULT 0.00,
                                         `montant_investissement_restant` decimal(15,2) NOT NULL DEFAULT 0.00,
                                         `montant_fonctionnement_restant` decimal(15,2) NOT NULL DEFAULT 0.00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `candidat`
--

CREATE TABLE `candidat` (
                            `id` bigint(20) NOT NULL,
                            `email` varchar(255) NOT NULL,
                            `password` varchar(255) DEFAULT NULL,
                            `nom` varchar(50) DEFAULT NULL,
                            `cin` varchar(50) DEFAULT NULL,
                            `phone` varchar(50) DEFAULT NULL,
                            `prenom` varchar(255) NOT NULL,
                            `blocked` int(11) NOT NULL,
                            `cnx_fail_number` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `categorie_produit`
--

CREATE TABLE `categorie_produit` (
                                     `id` bigint(20) NOT NULL,
                                     `libelle` varchar(255) NOT NULL,
                                     `code` varchar(50) NOT NULL,
                                     `style` varchar(50) DEFAULT NULL,
                                     `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `category_document_dossier_admin`
--

CREATE TABLE `category_document_dossier_admin` (
                                                   `id` bigint(20) NOT NULL,
                                                   `libelle` varchar(255) NOT NULL,
                                                   `code` varchar(255) NOT NULL,
                                                   `description` text DEFAULT NULL,
                                                   `badge` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `certificat_medical`
--

CREATE TABLE `certificat_medical` (
                                      `id` bigint(20) NOT NULL,
                                      `libelle` varchar(255) NOT NULL,
                                      `code` varchar(30) NOT NULL,
                                      `date` date NOT NULL,
                                      `student_id` bigint(20) NOT NULL,
                                      `fichier_pdf` varchar(255) NOT NULL,
                                      `message` text DEFAULT NULL,
                                      `semestre_id` bigint(20) DEFAULT NULL,
                                      `module_id` bigint(20) DEFAULT NULL,
                                      `type_examen` varchar(50) DEFAULT NULL,
                                      `annee_universitaire` varchar(20) DEFAULT NULL,
                                      `statut` varchar(20) NOT NULL DEFAULT 'en_attente',
                                      `reponse_admin` text DEFAULT NULL,
                                      `date_depot` datetime NOT NULL DEFAULT current_timestamp(),
                                      `date_traitement` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `commite_organisation_membre`
--

CREATE TABLE `commite_organisation_membre` (
                                               `id` bigint(20) NOT NULL,
                                               `employee_id` bigint(20) NOT NULL,
                                               `concours_id` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `concours`
--

CREATE TABLE `concours` (
                            `id` bigint(20) NOT NULL,
                            `code` varchar(255) NOT NULL,
                            `label` varchar(255) NOT NULL,
                            `description` text DEFAULT NULL,
                            `active` tinyint(1) DEFAULT NULL,
                            `filiere` varchar(255) DEFAULT NULL,
                            `date_lancement` datetime DEFAULT NULL,
                            `date_fin` datetime DEFAULT NULL,
                            `commite_organisation_id` bigint(20) DEFAULT NULL,
                            `etat_concours` varchar(100) DEFAULT NULL,
                            `date_fin_inscription` datetime DEFAULT NULL,
                            `date_affichage_ecrit` datetime DEFAULT NULL,
                            `date_ecrit` datetime DEFAULT NULL,
                            `date_affichage_orale` datetime DEFAULT NULL,
                            `date_orale` datetime DEFAULT NULL,
                            `date_affichage_resultat` datetime DEFAULT NULL,
                            `chef_commite_organisation` bigint(20) DEFAULT NULL,
                            `nbr_selection_initial` int(11) DEFAULT NULL,
                            `nbr_elegible_ecrit` int(11) DEFAULT NULL,
                            `nbr_elegible_oral` int(11) DEFAULT NULL,
                            `nbr_selection_finale` int(11) DEFAULT NULL,
                            `nbr_selection_attente` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `concours_detail`
--

CREATE TABLE `concours_detail` (
                                   `id` bigint(20) NOT NULL,
                                   `concours_id` bigint(20) NOT NULL,
                                   `type_diplome_id` int(11) NOT NULL,
                                   `pourcentage` decimal(5,2) DEFAULT NULL,
                                   `description` text DEFAULT NULL,
                                   `nbr_selection_initial` int(11) DEFAULT NULL,
                                   `nbr_elegible_ecrit` int(11) DEFAULT NULL,
                                   `nbr_elegible_oral` int(11) DEFAULT NULL,
                                   `nbr_selection_finale` int(11) DEFAULT NULL,
                                   `nbr_selection_attente` int(11) DEFAULT NULL,
                                   `pourcentage_selection_initial` int(11) DEFAULT NULL,
                                   `pourcentage_elegible_ecrit` int(11) DEFAULT NULL,
                                   `pourcentage_elegible_oral` int(11) DEFAULT NULL,
                                   `pourcentage_selection_finale` int(11) DEFAULT NULL,
                                   `pourcentage_selection_attente` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `demande`
--

CREATE TABLE `demande` (
                           `id` bigint(20) NOT NULL,
                           `libelle` varchar(255) NOT NULL,
                           `description` text DEFAULT NULL,
                           `date_demande` date DEFAULT NULL,
                           `montant_total` decimal(15,2) NOT NULL DEFAULT 0.00,
                           `montant_paye` decimal(15,2) NOT NULL DEFAULT 0.00,
                           `annee_universitaire_id` bigint(20) DEFAULT NULL,
                           `devis_demande_id` bigint(20) DEFAULT NULL,
                           `type_demande_id` bigint(20) NOT NULL,
                           `etat_demande_id` bigint(20) NOT NULL,
                           `fournisseur_id` bigint(20) NOT NULL,
                           `entite_administrative_id` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `demande_detail`
--

CREATE TABLE `demande_detail` (
                                  `id` bigint(20) NOT NULL,
                                  `categorie_produit_id` bigint(20) NOT NULL,
                                  `produit_id` bigint(20) NOT NULL,
                                  `quantite_demande` int(11) NOT NULL DEFAULT 0,
                                  `quantite_commande` int(11) NOT NULL DEFAULT 0,
                                  `quantite_receptionnee` int(11) NOT NULL DEFAULT 0,
                                  `quantite_livree` int(11) NOT NULL DEFAULT 0,
                                  `description` text DEFAULT NULL,
                                  `expression_besoin_id` bigint(20) DEFAULT NULL,
                                  `demande_id` bigint(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `demande_detail_repartition`
--

CREATE TABLE `demande_detail_repartition` (
                                              `id` bigint(20) NOT NULL,
                                              `demande_detail_id` bigint(20) NOT NULL,
                                              `produit_id` bigint(20) NOT NULL,
                                              `quantite_demande` int(11) NOT NULL DEFAULT 0,
                                              `quantite_commande` int(11) NOT NULL DEFAULT 0,
                                              `quantite_receptionnee` int(11) NOT NULL DEFAULT 0,
                                              `quantite_livree` int(11) NOT NULL DEFAULT 0,
                                              `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `demande_document`
--

CREATE TABLE `demande_document` (
                                    `id` bigint(20) NOT NULL,
                                    `employee_id` bigint(20) NOT NULL,
                                    `libelle` varchar(255) NOT NULL,
                                    `description` text DEFAULT NULL,
                                    `etat_demande_document_id` bigint(20) NOT NULL,
                                    `type_demande_document_id` bigint(20) NOT NULL,
                                    `date_soumission` date DEFAULT NULL,
                                    `date_reponse` date DEFAULT NULL,
                                    `date_creation` date NOT NULL DEFAULT current_timestamp(),
                                    `date_modification` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `demande_etudiant`
--

CREATE TABLE `demande_etudiant` (
                                    `id` int(11) NOT NULL,
                                    `student_id` int(11) NOT NULL,
                                    `etat_id` int(11) NOT NULL,
                                    `type_id` int(11) NOT NULL,
                                    `description` text DEFAULT NULL,
                                    `date_traitement` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `departement`
--

CREATE TABLE `departement` (
                               `id` bigint(20) NOT NULL,
                               `libelle` varchar(255) NOT NULL,
                               `code` varchar(50) NOT NULL,
                               `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `devis_demande`
--

CREATE TABLE `devis_demande` (
                                 `id` bigint(20) NOT NULL,
                                 `libelle` varchar(255) NOT NULL,
                                 `description` text DEFAULT NULL,
                                 `date_demande` date DEFAULT NULL,
                                 `montant_total` decimal(15,2) NOT NULL DEFAULT 0.00,
                                 `annee_universitaire_id` bigint(20) DEFAULT NULL,
                                 `type_devis_demande_id` bigint(20) NOT NULL,
                                 `etat_devis_demande_id` bigint(20) NOT NULL,
                                 `fournisseur_id` bigint(20) NOT NULL,
                                 `entite_administrative_id` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `devis_demande_detail`
--

CREATE TABLE `devis_demande_detail` (
                                        `id` bigint(20) NOT NULL,
                                        `categorie_produit_id` bigint(20) NOT NULL,
                                        `produit_id` bigint(20) NOT NULL,
                                        `quantite` int(11) NOT NULL DEFAULT 0,
                                        `description` text DEFAULT NULL,
                                        `expression_besoin_id` bigint(20) DEFAULT NULL,
                                        `devis_demande_id` bigint(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `document_dossier_admin`
--

CREATE TABLE `document_dossier_admin` (
                                          `id` bigint(20) NOT NULL,
                                          `employee_id` bigint(20) NOT NULL,
                                          `departement_id` bigint(20) DEFAULT NULL,
                                          `original_name` text NOT NULL,
                                          `stored_name` text NOT NULL,
                                          `mime_type_id` bigint(20) NOT NULL,
                                          `size` bigint(20) NOT NULL,
                                          `category_id` bigint(20) NOT NULL,
                                          `note` text DEFAULT NULL,
                                          `uploaded_at` datetime NOT NULL,
                                          `uploaded_by` bigint(20) NOT NULL,
                                          `expiry_date` date DEFAULT NULL,
                                          `annee_univ` int(4) DEFAULT NULL,
                                          `is_verified` int(1) NOT NULL DEFAULT 0,
                                          `verified_by` bigint(20) DEFAULT NULL,
                                          `verified_at` datetime DEFAULT NULL,
                                          `etat_document_dossier_administratif_id` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `echelle`
--

CREATE TABLE `echelle` (
                           `id` bigint(20) NOT NULL,
                           `libelle` varchar(255) NOT NULL,
                           `code` varchar(100) NOT NULL,
                           `description` text DEFAULT NULL,
                           `grade_id` bigint(20) NOT NULL,
                           `echellon_depart` int(11) NOT NULL,
                           `echellon_fin` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `echellon`
--

CREATE TABLE `echellon` (
                            `id` bigint(20) NOT NULL,
                            `libelle` varchar(255) NOT NULL,
                            `code` varchar(100) NOT NULL,
                            `description` text DEFAULT NULL,
                            `echelle_id` bigint(20) NOT NULL,
                            `echellon_suivant_id` bigint(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `employee`
--

CREATE TABLE `employee` (
                            `id` bigint(20) NOT NULL,
                            `code` varchar(255) NOT NULL,
                            `nom` varchar(255) NOT NULL,
                            `nom_arab` varchar(255) NOT NULL,
                            `prenom` varchar(255) NOT NULL,
                            `prenom_arab` varchar(255) NOT NULL,
                            `cin` varchar(255) NOT NULL,
                            `email` varchar(255) NOT NULL,
                            `login` varchar(255) NOT NULL,
                            `password` varchar(255) NOT NULL,
                            `specialite` varchar(255) NOT NULL,
                            `diplome` varchar(255) NOT NULL,
                            `genre` varchar(255) NOT NULL,
                            `etablissement_diplome` varchar(255) NOT NULL,
                            `lieu_naissance` varchar(255) NOT NULL,
                            `date_naissance` date NOT NULL,
                            `fonctionnaire` tinyint(1) DEFAULT 0,
                            `nombre_annee_fonctionnaire` int(11) DEFAULT 0,
                            `date_recrutement` date NOT NULL,
                            `date_affectation_enseignement` date NOT NULL,
                            `status` varchar(255) NOT NULL,
                            `phone` varchar(255) NOT NULL,
                            `grade_id` bigint(20) DEFAULT NULL,
                            `type_grade_id` bigint(20) DEFAULT NULL,
                            `echellon_id` bigint(20) DEFAULT NULL,
                            `departement_id` bigint(20) DEFAULT NULL,
                            `blocked` int(11) NOT NULL DEFAULT 0,
                            `cnx_fail_number` int(11) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `entite_administrative`
--

CREATE TABLE `entite_administrative` (
                                         `id` bigint(20) NOT NULL,
                                         `libelle` varchar(255) NOT NULL,
                                         `code` varchar(50) NOT NULL,
                                         `style` varchar(50) DEFAULT NULL,
                                         `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `etat_avancement`
--

CREATE TABLE `etat_avancement` (
                                   `id` bigint(20) NOT NULL,
                                   `libelle` varchar(255) NOT NULL,
                                   `code` varchar(100) NOT NULL,
                                   `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `etat_budget_faculte`
--

CREATE TABLE `etat_budget_faculte` (
                                       `id` bigint(20) NOT NULL,
                                       `libelle` varchar(255) NOT NULL,
                                       `code` varchar(50) NOT NULL,
                                       `style` varchar(50) DEFAULT NULL,
                                       `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `etat_demande`
--

CREATE TABLE `etat_demande` (
                                `id` bigint(20) NOT NULL,
                                `libelle` varchar(255) NOT NULL,
                                `code` varchar(50) NOT NULL,
                                `style` varchar(50) DEFAULT NULL,
                                `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `etat_demande_document`
--

CREATE TABLE `etat_demande_document` (
                                         `id` bigint(20) NOT NULL,
                                         `libelle` varchar(255) NOT NULL,
                                         `code` varchar(100) NOT NULL,
                                         `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `etat_demande_etudiant`
--

CREATE TABLE `etat_demande_etudiant` (
                                         `id` int(11) NOT NULL,
                                         `code` varchar(50) NOT NULL,
                                         `libelle` varchar(100) NOT NULL,
                                         `budge` decimal(10,2) DEFAULT 0.00,
                                         `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `etat_devis_demande`
--

CREATE TABLE `etat_devis_demande` (
                                      `id` bigint(20) NOT NULL,
                                      `libelle` varchar(255) NOT NULL,
                                      `code` varchar(50) NOT NULL,
                                      `style` varchar(50) DEFAULT NULL,
                                      `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `etat_document_dossier_administratif`
--

CREATE TABLE `etat_document_dossier_administratif` (
                                                       `id` int(11) NOT NULL,
                                                       `code` varchar(50) NOT NULL,
                                                       `libelle` varchar(100) NOT NULL,
                                                       `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `etat_expression_besoin`
--

CREATE TABLE `etat_expression_besoin` (
                                          `id` bigint(20) NOT NULL,
                                          `libelle` varchar(255) NOT NULL,
                                          `code` varchar(50) NOT NULL,
                                          `style` varchar(50) DEFAULT NULL,
                                          `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `etat_livraison`
--

CREATE TABLE `etat_livraison` (
                                  `id` bigint(20) NOT NULL,
                                  `libelle` varchar(255) NOT NULL,
                                  `code` varchar(50) NOT NULL,
                                  `style` varchar(50) DEFAULT NULL,
                                  `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `etat_paiement`
--

CREATE TABLE `etat_paiement` (
                                 `id` bigint(20) NOT NULL,
                                 `libelle` varchar(255) NOT NULL,
                                 `code` varchar(50) NOT NULL,
                                 `style` varchar(50) DEFAULT NULL,
                                 `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `etat_reception`
--

CREATE TABLE `etat_reception` (
                                  `id` bigint(20) NOT NULL,
                                  `libelle` varchar(255) NOT NULL,
                                  `code` varchar(50) NOT NULL,
                                  `style` varchar(50) DEFAULT NULL,
                                  `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `etat_student`
--

CREATE TABLE `etat_student` (
                                `id` bigint(20) NOT NULL,
                                `libelle` varchar(255) NOT NULL,
                                `code` varchar(50) NOT NULL,
                                `style` varchar(50) DEFAULT NULL,
                                `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `expression_besoin`
--

CREATE TABLE `expression_besoin` (
                                     `id` bigint(20) NOT NULL,
                                     `libelle` varchar(255) NOT NULL,
                                     `description` text DEFAULT NULL,
                                     `annee_budgitaire_id` bigint(20) NOT NULL,
                                     `employee_id` bigint(20) NOT NULL,
                                     `etat_expression_besoin_id` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `expression_besoin_detail`
--

CREATE TABLE `expression_besoin_detail` (
                                            `id` bigint(20) NOT NULL,
                                            `libelle` varchar(255) NOT NULL,
                                            `categorie_produit_id` bigint(20) NOT NULL,
                                            `description` text DEFAULT NULL,
                                            `quantite_demande` int(11) NOT NULL DEFAULT 0,
                                            `quantite_approvee` int(11) NOT NULL DEFAULT 0,
                                            `quantite_commande` int(11) NOT NULL DEFAULT 0,
                                            `quantite_receptionnee` int(11) NOT NULL DEFAULT 0,
                                            `quantite_livree` int(11) NOT NULL DEFAULT 0,
                                            `expression_besoin_id` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `filiere`
--

CREATE TABLE `filiere` (
                           `id` bigint(20) NOT NULL,
                           `libelle` varchar(255) NOT NULL,
                           `code` varchar(50) NOT NULL,
                           `description` text DEFAULT NULL,
                           `departement_id` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `fournisseur`
--

CREATE TABLE `fournisseur` (
                               `id` bigint(20) NOT NULL,
                               `nom` varchar(255) NOT NULL,
                               `prenom` varchar(255) DEFAULT NULL,
                               `adresse` varchar(255) DEFAULT NULL,
                               `code` varchar(50) NOT NULL,
                               `phone` varchar(50) DEFAULT NULL,
                               `email` varchar(255) DEFAULT NULL,
                               `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `grade`
--

CREATE TABLE `grade` (
                         `id` bigint(20) NOT NULL,
                         `libelle` varchar(255) NOT NULL,
                         `code` varchar(100) NOT NULL,
                         `description` text DEFAULT NULL,
                         `type_grade_id` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `inscription_concours`
--

CREATE TABLE `inscription_concours` (
                                        `id` bigint(20) NOT NULL,
                                        `code` varchar(255) NOT NULL,
                                        `civilite` varchar(20) DEFAULT NULL COMMENT 'Civilité: Monsieur, Madame, Mademoiselle',
                                        `email` varchar(255) DEFAULT NULL COMMENT 'Adresse e-mail',
                                        `prenom` varchar(100) DEFAULT NULL COMMENT 'Prénom en français',
                                        `nom` varchar(100) DEFAULT NULL COMMENT 'Nom en français',
                                        `prenom_arabe` varchar(100) DEFAULT NULL COMMENT 'الاسم الشخصي (Arabe)',
                                        `nom_arabe` varchar(100) DEFAULT NULL COMMENT 'الاسم العائلي (Arabe)',
                                        `cin` varchar(20) DEFAULT NULL COMMENT 'Carte d''identité nationale',
                                        `telephone` varchar(20) DEFAULT NULL COMMENT 'Numéro de téléphone',
                                        `photo` varchar(255) DEFAULT NULL COMMENT 'Photo d''identité (chemin du fichier)',
                                        `situation_familiale` varchar(30) DEFAULT NULL COMMENT 'Situation familiale: Célibataire, Marié(e), Divorcé(e),\r\n        Veuf(ve)',
                                        `date_naissance` date DEFAULT NULL COMMENT 'Date de naissance',
                                        `lieu_naissance` varchar(255) DEFAULT NULL COMMENT 'Lieu de naissance (Français)',
                                        `lieu_naissance_arabe` varchar(255) DEFAULT NULL COMMENT 'Lieu de naissance (Arabe)',
                                        `province_naissance` varchar(100) DEFAULT NULL COMMENT 'Province de naissance',
                                        `nationalite` varchar(50) DEFAULT NULL COMMENT 'Nationalité',
                                        `adresse` varchar(255) DEFAULT NULL COMMENT 'Adresse (Français)',
                                        `adresse_arabe` varchar(255) DEFAULT NULL COMMENT 'Adresse (Arabe)',
                                        `code_postal` varchar(10) DEFAULT NULL COMMENT 'Code postal',
                                        `province_residence` varchar(100) DEFAULT NULL COMMENT 'Province de résidence',
                                        `situation_professionnelle` varchar(50) DEFAULT NULL COMMENT 'Situation professionnelle: Non employé, Employé,\r\n        Fonctionnaire, Étudiant, Autre',
                                        `label` varchar(255) DEFAULT NULL,
                                        `active` tinyint(1) DEFAULT NULL,
                                        `description` text DEFAULT NULL,
                                        `concours_id` bigint(20) DEFAULT NULL,
                                        `candidat_id` bigint(20) DEFAULT NULL,
                                        `annee_bac` bigint(20) DEFAULT NULL,
                                        `specialite_bac` varchar(255) DEFAULT NULL,
                                        `mention_bac` varchar(255) DEFAULT NULL,
                                        `type_etablissement_bac` varchar(255) DEFAULT NULL,
                                        `province` varchar(255) DEFAULT NULL,
                                        `moyenne_general_bac` decimal(10,2) DEFAULT NULL,
                                        `etat_inscription` varchar(100) DEFAULT NULL,
                                        `bac_recto` varchar(500) DEFAULT NULL,
                                        `bac_verso` varchar(500) DEFAULT NULL,
                                        `type_diplome_obtenu` int(11) DEFAULT NULL,
                                        `specialite_diplome` varchar(255) DEFAULT NULL,
                                        `anne_obtention_diplome` bigint(20) DEFAULT NULL,
                                        `etablissement_origine` varchar(255) DEFAULT NULL,
                                        `module_valide` tinyint(1) DEFAULT NULL,
                                        `duree_diplome` bigint(20) DEFAULT NULL,
                                        `note_s1` decimal(10,2) DEFAULT NULL,
                                        `note_s2` decimal(10,2) DEFAULT NULL,
                                        `note_s3` decimal(10,2) DEFAULT NULL,
                                        `note_s4` decimal(10,2) DEFAULT NULL,
                                        `note_s5` decimal(10,2) DEFAULT NULL,
                                        `note_s6` decimal(10,2) DEFAULT NULL,
                                        `moyenne_general_calcule` decimal(10,2) DEFAULT NULL,
                                        `moyenne_ecrit` decimal(10,2) DEFAULT NULL,
                                        `moyenne_orale` decimal(10,2) DEFAULT NULL,
                                        `resultat_inscription` varchar(100) DEFAULT NULL,
                                        `attestation_reusite` varchar(500) DEFAULT NULL,
                                        `releves_notes` varchar(500) DEFAULT NULL,
                                        `demande_maniscrite` varchar(500) DEFAULT NULL,
                                        `cv` varchar(500) DEFAULT NULL,
                                        `cin_recto` varchar(500) DEFAULT NULL,
                                        `cin_verso` varchar(500) DEFAULT NULL,
                                        `date_inscription` date DEFAULT current_timestamp(),
                                        `date_creation` date DEFAULT current_timestamp(),
                                        `date_modification` date DEFAULT NULL,
                                        `code_massar` varchar(255) DEFAULT NULL,
                                        `province_bac` varchar(255) DEFAULT NULL,
                                        `moyenne_bac` decimal(10,2) DEFAULT NULL,
                                        `type_diplome` varchar(255) DEFAULT NULL,
                                        `annee_diplome` int(11) DEFAULT NULL,
                                        `modules_valides` int(11) DEFAULT NULL,
                                        `diplome` varchar(255) DEFAULT NULL,
                                        `moyenne_calcule_avant_ecrit` decimal(10,2) DEFAULT NULL,
                                        `moyenne_calcule_avant_orale` decimal(10,2) DEFAULT NULL,
                                        `moyenne_calcule_avant_finale` decimal(10,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `inscription_etudiant`
--

CREATE TABLE `inscription_etudiant` (
                                        `id` bigint(20) NOT NULL,
                                        `student_id` bigint(20) NOT NULL,
                                        `filiere_id` bigint(20) NOT NULL,
                                        `annee_universitaire_id` bigint(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `livraison`
--

CREATE TABLE `livraison` (
                             `id` bigint(20) NOT NULL,
                             `libelle` varchar(255) NOT NULL,
                             `description` text DEFAULT NULL,
                             `demande_id` bigint(20) NOT NULL,
                             `date_livraison` date DEFAULT NULL,
                             `annee_universitaire_id` bigint(20) DEFAULT NULL,
                             `etat_livraison_id` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `livraison_detail`
--

CREATE TABLE `livraison_detail` (
                                    `id` bigint(20) NOT NULL,
                                    `magasin_id` bigint(20) NOT NULL,
                                    `entite_administrative_id` bigint(20) NOT NULL,
                                    `categorie_produit_id` bigint(20) NOT NULL,
                                    `produit_id` bigint(20) NOT NULL,
                                    `quantite` int(11) NOT NULL DEFAULT 0,
                                    `description` text DEFAULT NULL,
                                    `livraison_id` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `magasin`
--

CREATE TABLE `magasin` (
                           `id` bigint(20) NOT NULL,
                           `libelle` varchar(255) NOT NULL,
                           `code` varchar(50) NOT NULL,
                           `adresse` varchar(255) DEFAULT NULL,
                           `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `mime_document_dossier_admin`
--

CREATE TABLE `mime_document_dossier_admin` (
                                               `id` bigint(20) NOT NULL,
                                               `libelle` varchar(255) NOT NULL,
                                               `code` varchar(255) NOT NULL,
                                               `description` text DEFAULT NULL,
                                               `badge` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `module`
--

CREATE TABLE `module` (
                          `id` bigint(20) NOT NULL,
                          `libelle` varchar(255) NOT NULL,
                          `code` varchar(50) NOT NULL,
                          `description` text DEFAULT NULL,
                          `filiere_id` bigint(20) NOT NULL,
                          `filiere_origine_id` bigint(20) DEFAULT NULL,
                          `charge_horaire_cours` int(11) DEFAULT 0,
                          `charge_horaire_tp` int(11) DEFAULT 0,
                          `charge_horaire_td` int(11) DEFAULT 0,
                          `coefficient_cours` int(11) NOT NULL DEFAULT 1,
                          `coefficient_td` int(11) NOT NULL DEFAULT 1,
                          `coefficient_tp` int(11) NOT NULL DEFAULT 1,
                          `evaluation` int(11) NOT NULL DEFAULT 4,
                          `nombre_groupe_cours` int(11) DEFAULT 1,
                          `nombre_groupe_tp` int(11) DEFAULT 1,
                          `nombre_groupe_td` int(11) DEFAULT 1,
                          `semestre_id` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `note_semestre`
--

CREATE TABLE `note_semestre` (
                                 `id` bigint(20) NOT NULL,
                                 `departement_id` bigint(20) DEFAULT NULL,
                                 `filiere_id` bigint(20) DEFAULT NULL,
                                 `semestre_id` bigint(20) NOT NULL,
                                 `student_id` bigint(20) NOT NULL,
                                 `note_avant_ratt` decimal(5,2) DEFAULT NULL,
                                 `decision_avant_ratt` varchar(50) DEFAULT NULL,
                                 `note_apres_ratt` decimal(5,2) DEFAULT NULL,
                                 `decision_apres_ratt` varchar(50) DEFAULT NULL,
                                 `annee_universitaire_id` bigint(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `note_semestre_detail`
--

CREATE TABLE `note_semestre_detail` (
                                        `id` bigint(20) NOT NULL,
                                        `note_semestre_id` bigint(20) NOT NULL,
                                        `module_id` bigint(20) NOT NULL,
                                        `note_avant_ratt_cc` decimal(5,2) DEFAULT NULL,
                                        `note_avant_ratt_cf` decimal(5,2) DEFAULT NULL,
                                        `note_avant_ratt` decimal(5,2) DEFAULT NULL,
                                        `decision_avant_ratt` varchar(50) DEFAULT NULL,
                                        `note_apres_ratt` decimal(5,2) DEFAULT NULL,
                                        `decision_apres_ratt` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `paiement_demande`
--

CREATE TABLE `paiement_demande` (
                                    `id` bigint(20) NOT NULL,
                                    `libelle` varchar(255) NOT NULL,
                                    `description` text DEFAULT NULL,
                                    `date_paiement` date DEFAULT NULL,
                                    `montant` decimal(15,2) NOT NULL DEFAULT 0.00,
                                    `annee_universitaire_id` bigint(20) DEFAULT NULL,
                                    `demande_id` bigint(20) NOT NULL,
                                    `type_paiement_id` bigint(20) NOT NULL,
                                    `etat_paiement_id` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `presence`
--

CREATE TABLE `presence` (
                            `id` bigint(20) NOT NULL,
                            `affectation_module_id` bigint(20) NOT NULL,
                            `libelle` varchar(255) NOT NULL,
                            `type_seance` varchar(20) DEFAULT 'Cours',
                            `description` text DEFAULT NULL,
                            `date_seance` date DEFAULT NULL,
                            `heure_debut` time DEFAULT '08:00:00',
                            `nb_heures` int(11) DEFAULT 2,
                            `jour_semaine` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `presence_detail`
--

CREATE TABLE `presence_detail` (
                                   `id` bigint(20) NOT NULL,
                                   `presence_id` bigint(20) NOT NULL,
                                   `student_id` bigint(20) NOT NULL,
                                   `present` tinyint(1) NOT NULL DEFAULT 0 COMMENT '1=Présent (P), 0=Absent (A)',
                                   `description` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `produit`
--

CREATE TABLE `produit` (
                           `id` bigint(20) NOT NULL,
                           `libelle` varchar(255) NOT NULL,
                           `code` varchar(50) NOT NULL,
                           `style` varchar(50) DEFAULT NULL,
                           `description` text DEFAULT NULL,
                           `categorie_produit_id` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `professeur`
--

CREATE TABLE `professeur` (
                              `id` bigint(20) NOT NULL,
                              `code` varchar(255) NOT NULL,
                              `nom` varchar(255) NOT NULL,
                              `prenom` varchar(255) NOT NULL,
                              `cin` varchar(255) NOT NULL,
                              `email` varchar(255) NOT NULL,
                              `login` varchar(255) NOT NULL,
                              `password` varchar(255) NOT NULL,
                              `specialite` varchar(255) NOT NULL,
                              `status` varchar(255) NOT NULL,
                              `phone` varchar(255) NOT NULL,
                              `grade_id` bigint(20) DEFAULT NULL,
                              `echellon_id` bigint(20) DEFAULT NULL,
                              `blocked` int(11) NOT NULL,
                              `cnx_fail_number` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `reception`
--

CREATE TABLE `reception` (
                             `id` bigint(20) NOT NULL,
                             `libelle` varchar(255) NOT NULL,
                             `description` text DEFAULT NULL,
                             `demande_id` bigint(20) NOT NULL,
                             `date_reception` date DEFAULT NULL,
                             `annee_universitaire_id` bigint(20) DEFAULT NULL,
                             `etat_reception_id` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `reception_detail`
--

CREATE TABLE `reception_detail` (
                                    `id` bigint(20) NOT NULL,
                                    `magasin_id` bigint(20) NOT NULL,
                                    `categorie_produit_id` bigint(20) NOT NULL,
                                    `produit_id` bigint(20) NOT NULL,
                                    `quantite` int(11) NOT NULL DEFAULT 0,
                                    `description` text DEFAULT NULL,
                                    `reception_id` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `reclamation_note`
--

CREATE TABLE `reclamation_note` (
                                    `id` bigint(20) NOT NULL,
                                    `note_semestre_detail_id` bigint(20) NOT NULL,
                                    `student_id` bigint(20) NOT NULL,
                                    `type` varchar(50) NOT NULL,
                                    `message` text NOT NULL,
                                    `statut` varchar(20) NOT NULL DEFAULT 'en_attente',
                                    `reponse_admin` text DEFAULT NULL,
                                    `date_reclamation` datetime NOT NULL DEFAULT current_timestamp(),
                                    `date_traitement` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `resultat_concours`
--

CREATE TABLE `resultat_concours` (
                                     `id` int(11) NOT NULL,
                                     `libelle` varchar(150) NOT NULL,
                                     `code` varchar(50) NOT NULL,
                                     `description` text DEFAULT NULL,
                                     `order_preparation_ecrit` int(11) DEFAULT 0,
                                     `badge_preparation_ecrit` int(11) DEFAULT 0,
                                     `order_preparation_orale` int(11) DEFAULT 0,
                                     `badge_preparation_orale` int(11) DEFAULT 0,
                                     `order_resultat_finale` int(11) DEFAULT 0,
                                     `badge_resultat_finale` int(11) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `semestre`
--

CREATE TABLE `semestre` (
                            `id` bigint(20) NOT NULL,
                            `libelle` varchar(255) NOT NULL,
                            `code` varchar(50) NOT NULL,
                            `description` text DEFAULT NULL,
                            `annee_universitaire_id` bigint(20) DEFAULT NULL,
                            `date_debut` date NOT NULL,
                            `date_fin` date NOT NULL,
                            `date_creation` date NOT NULL,
                            `date_modification` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `sg`
--

CREATE TABLE `sg` (
                      `id` bigint(20) NOT NULL,
                      `code` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `stock`
--

CREATE TABLE `stock` (
                         `id` bigint(20) NOT NULL,
                         `produit_id` bigint(20) NOT NULL,
                         `magasin_id` bigint(20) NOT NULL,
                         `quantite` int(11) NOT NULL DEFAULT 0,
                         `seuil_alert` int(11) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `student`
--

CREATE TABLE `student` (
                           `id` bigint(20) NOT NULL,
                           `email` varchar(255) NOT NULL,
                           `password` varchar(255) DEFAULT NULL,
                           `nom` varchar(50) DEFAULT NULL,
                           `cin` varchar(50) DEFAULT NULL,
                           `phone` varchar(50) DEFAULT NULL,
                           `prenom` varchar(255) NOT NULL,
                           `blocked` int(11) NOT NULL,
                           `cnx_fail_number` int(11) NOT NULL,
                           `cine` varchar(255) NOT NULL,
                           `filiere_id` bigint(20) DEFAULT NULL,
                           `annee_universitaire_debut_id` bigint(20) DEFAULT NULL,
                           `annee_universitaire_fin_id` bigint(20) DEFAULT NULL,
                           `semestre_id` bigint(20) DEFAULT NULL,
                           `etat_student_id` bigint(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `type_demande`
--

CREATE TABLE `type_demande` (
                                `id` bigint(20) NOT NULL,
                                `libelle` varchar(255) NOT NULL,
                                `code` varchar(50) NOT NULL,
                                `style` varchar(50) DEFAULT NULL,
                                `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `type_demande_document`
--

CREATE TABLE `type_demande_document` (
                                         `id` bigint(20) NOT NULL,
                                         `libelle` varchar(255) NOT NULL,
                                         `code` varchar(100) NOT NULL,
                                         `description` text DEFAULT NULL,
                                         `template_document` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `type_demande_etudiant`
--

CREATE TABLE `type_demande_etudiant` (
                                         `id` int(11) NOT NULL,
                                         `code` varchar(50) NOT NULL,
                                         `libelle` varchar(100) NOT NULL,
                                         `budge` decimal(10,2) DEFAULT 0.00,
                                         `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `type_devis_demande`
--

CREATE TABLE `type_devis_demande` (
                                      `id` bigint(20) NOT NULL,
                                      `libelle` varchar(255) NOT NULL,
                                      `code` varchar(50) NOT NULL,
                                      `style` varchar(50) DEFAULT NULL,
                                      `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `type_diplome`
--

CREATE TABLE `type_diplome` (
                                `id` int(11) NOT NULL,
                                `code` varchar(255) NOT NULL,
                                `libelle` varchar(255) NOT NULL,
                                `annee_apres_bac` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `type_document_dossier_administratif`
--

CREATE TABLE `type_document_dossier_administratif` (
                                                       `id` bigint(20) NOT NULL,
                                                       `libelle` varchar(255) NOT NULL,
                                                       `code` varchar(100) NOT NULL,
                                                       `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `type_grade`
--

CREATE TABLE `type_grade` (
                              `id` bigint(20) NOT NULL,
                              `libelle` varchar(255) NOT NULL,
                              `code` varchar(100) NOT NULL,
                              `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Structure de la table `type_paiement`
--

CREATE TABLE `type_paiement` (
                                 `id` bigint(20) NOT NULL,
                                 `libelle` varchar(255) NOT NULL,
                                 `code` varchar(50) NOT NULL,
                                 `style` varchar(50) DEFAULT NULL,
                                 `description` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Index pour les tables déchargées
--

--
-- Index pour la table `admin`
--
ALTER TABLE `admin`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`email`);

--
-- Index pour la table `affectation_module`
--
ALTER TABLE `affectation_module`
    ADD PRIMARY KEY (`id`),
  ADD KEY `fk_affectation_filiere` (`filiere_id`),
  ADD KEY `fk_affectation_semestre` (`semestre_id`),
  ADD KEY `idx_affectation_module` (`module_id`),
  ADD KEY `idx_affectation_employee` (`employee_id`),
  ADD KEY `fk_affectation_module_annee` (`annee_universitaire_id`);

--
-- Index pour la table `annee_budgitaire`
--
ALTER TABLE `annee_budgitaire`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `annee_universitaire`
--
ALTER TABLE `annee_universitaire`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `avancement_type`
--
ALTER TABLE `avancement_type`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uk_avancement_type_code` (`code`);

--
-- Index pour la table `budget_faculte`
--
ALTER TABLE `budget_faculte`
    ADD PRIMARY KEY (`id`),
  ADD KEY `fk_budget_faculte_annee` (`annee_budgitaire_id`),
  ADD KEY `fk_budget_faculte_etat` (`etat_budget_faculte_id`);

--
-- Index pour la table `budget_faculte_detail`
--
ALTER TABLE `budget_faculte_detail`
    ADD PRIMARY KEY (`id`),
  ADD KEY `fk_budget_detail_budget` (`budget_faculte_id`),
  ADD KEY `fk_budget_detail_entite` (`entite_administrative_id`);

--
-- Index pour la table `candidat`
--
ALTER TABLE `candidat`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`email`);

--
-- Index pour la table `categorie_produit`
--
ALTER TABLE `categorie_produit`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `category_document_dossier_admin`
--
ALTER TABLE `category_document_dossier_admin`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `certificat_medical`
--
ALTER TABLE `certificat_medical`
    ADD PRIMARY KEY (`id`),
  ADD KEY `idx_student` (`student_id`),
  ADD KEY `idx_code` (`code`),
  ADD KEY `idx_statut` (`statut`),
  ADD KEY `idx_module` (`module_id`),
  ADD KEY `idx_semestre` (`semestre_id`);

--
-- Index pour la table `commite_organisation_membre`
--
ALTER TABLE `commite_organisation_membre`
    ADD PRIMARY KEY (`id`),
  ADD KEY `idx_com_employee` (`employee_id`),
  ADD KEY `idx_com_concours` (`concours_id`);

--
-- Index pour la table `concours`
--
ALTER TABLE `concours`
    ADD PRIMARY KEY (`id`),
  ADD KEY `fk_concours_chef_commite` (`chef_commite_organisation`);

--
-- Index pour la table `concours_detail`
--
ALTER TABLE `concours_detail`
    ADD PRIMARY KEY (`id`),
  ADD KEY `fk_concours_detail_concours` (`concours_id`),
  ADD KEY `fk_concours_detail_type_diplome` (`type_diplome_id`);

--
-- Index pour la table `demande`
--
ALTER TABLE `demande`
    ADD PRIMARY KEY (`id`),
  ADD KEY `fk_demande_annee` (`annee_universitaire_id`),
  ADD KEY `fk_demande_devis` (`devis_demande_id`),
  ADD KEY `fk_demande_type` (`type_demande_id`),
  ADD KEY `fk_demande_etat` (`etat_demande_id`),
  ADD KEY `fk_demande_fournisseur` (`fournisseur_id`),
  ADD KEY `fk_demande_entite` (`entite_administrative_id`);

--
-- Index pour la table `demande_detail`
--
ALTER TABLE `demande_detail`
    ADD PRIMARY KEY (`id`),
  ADD KEY `fk_demandd_categorie` (`categorie_produit_id`),
  ADD KEY `fk_demandd_produit` (`produit_id`),
  ADD KEY `fk_demandd_expression` (`expression_besoin_id`);

--
-- Index pour la table `demande_detail_repartition`
--
ALTER TABLE `demande_detail_repartition`
    ADD PRIMARY KEY (`id`),
  ADD KEY `fk_repart_demande_detail` (`demande_detail_id`),
  ADD KEY `fk_repart_produit` (`produit_id`);

--
-- Index pour la table `demande_document`
--
ALTER TABLE `demande_document`
    ADD PRIMARY KEY (`id`),
  ADD KEY `fk_demande_document_employee` (`employee_id`),
  ADD KEY `fk_demande_document_etat` (`etat_demande_document_id`),
  ADD KEY `fk_demande_demande_document_type` (`type_demande_document_id`),
  ADD KEY `idx_demande_document_date_soumission` (`date_soumission`),
  ADD KEY `idx_demande_document_employee_date` (`employee_id`,`date_soumission`);

--
-- Index pour la table `demande_etudiant`
--
ALTER TABLE `demande_etudiant`
    ADD PRIMARY KEY (`id`),
  ADD KEY `fk_etat_demande` (`etat_id`),
  ADD KEY `fk_type_demande` (`type_id`);

--
-- Index pour la table `departement`
--
ALTER TABLE `departement`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `devis_demande`
--
ALTER TABLE `devis_demande`
    ADD PRIMARY KEY (`id`),
  ADD KEY `fk_devis_annee` (`annee_universitaire_id`),
  ADD KEY `fk_devis_type` (`type_devis_demande_id`),
  ADD KEY `fk_devis_etat` (`etat_devis_demande_id`),
  ADD KEY `fk_devis_fournisseur` (`fournisseur_id`),
  ADD KEY `fk_devis_entite` (`entite_administrative_id`);

--
-- Index pour la table `devis_demande_detail`
--
ALTER TABLE `devis_demande_detail`
    ADD PRIMARY KEY (`id`),
  ADD KEY `fk_devisd_categorie` (`categorie_produit_id`),
  ADD KEY `fk_devisd_produit` (`produit_id`),
  ADD KEY `fk_devisd_expression` (`expression_besoin_id`);

--
-- Index pour la table `document_dossier_admin`
--
ALTER TABLE `document_dossier_admin`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uk_document_stored_name` (`stored_name`(255)),
  ADD KEY `idx_document_employee` (`employee_id`),
  ADD KEY `idx_document_category` (`category_id`),
  ADD KEY `idx_document_mime` (`mime_type_id`),
  ADD KEY `idx_document_etat` (`etat_document_dossier_administratif_id`),
  ADD KEY `idx_document_uploaded_by` (`uploaded_by`),
  ADD KEY `idx_document_verified_by` (`verified_by`),
  ADD KEY `idx_document_departement` (`departement_id`);

--
-- Index pour la table `echelle`
--
ALTER TABLE `echelle`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uk_echelle_code` (`code`),
  ADD KEY `fk_echelle_grade` (`grade_id`);

--
-- Index pour la table `echellon`
--
ALTER TABLE `echellon`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uk_echellon_code` (`code`),
  ADD KEY `fk_echellon_echelle` (`echelle_id`),
  ADD KEY `fk_echellon_suivant` (`echellon_suivant_id`);

--
-- Index pour la table `employee`
--
ALTER TABLE `employee`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`),
  ADD UNIQUE KEY `email` (`email`),
  ADD UNIQUE KEY `login` (`login`),
  ADD KEY `fk_employee_grade` (`grade_id`),
  ADD KEY `fk_employee_type_grade` (`type_grade_id`),
  ADD KEY `fk_employee_echellon` (`echellon_id`),
  ADD KEY `fk_employee_departement` (`departement_id`);

--
-- Index pour la table `entite_administrative`
--
ALTER TABLE `entite_administrative`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `etat_avancement`
--
ALTER TABLE `etat_avancement`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uk_etat_avancement_code` (`code`);

--
-- Index pour la table `etat_budget_faculte`
--
ALTER TABLE `etat_budget_faculte`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `etat_demande`
--
ALTER TABLE `etat_demande`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `etat_demande_document`
--
ALTER TABLE `etat_demande_document`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uk_etat_demande_document_code` (`code`);

--
-- Index pour la table `etat_demande_etudiant`
--
ALTER TABLE `etat_demande_etudiant`
    ADD PRIMARY KEY (`id`);

--
-- Index pour la table `etat_devis_demande`
--
ALTER TABLE `etat_devis_demande`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `etat_document_dossier_administratif`
--
ALTER TABLE `etat_document_dossier_administratif`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `etat_expression_besoin`
--
ALTER TABLE `etat_expression_besoin`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `etat_livraison`
--
ALTER TABLE `etat_livraison`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `etat_paiement`
--
ALTER TABLE `etat_paiement`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `etat_reception`
--
ALTER TABLE `etat_reception`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `etat_student`
--
ALTER TABLE `etat_student`
    ADD PRIMARY KEY (`id`);

--
-- Index pour la table `expression_besoin`
--
ALTER TABLE `expression_besoin`
    ADD PRIMARY KEY (`id`),
  ADD KEY `fk_eb_annee` (`annee_budgitaire_id`),
  ADD KEY `fk_eb_employee` (`employee_id`),
  ADD KEY `fk_eb_etat` (`etat_expression_besoin_id`);

--
-- Index pour la table `expression_besoin_detail`
--
ALTER TABLE `expression_besoin_detail`
    ADD PRIMARY KEY (`id`),
  ADD KEY `fk_ebd_categorie` (`categorie_produit_id`),
  ADD KEY `fk_ebd_expression` (`expression_besoin_id`);

--
-- Index pour la table `filiere`
--
ALTER TABLE `filiere`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`),
  ADD KEY `idx_filiere_departement` (`departement_id`);

--
-- Index pour la table `fournisseur`
--
ALTER TABLE `fournisseur`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`),
  ADD UNIQUE KEY `email` (`email`);

--
-- Index pour la table `grade`
--
ALTER TABLE `grade`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uk_grade_code` (`code`),
  ADD KEY `fk_grade_type_grade` (`type_grade_id`);

--
-- Index pour la table `inscription_concours`
--
ALTER TABLE `inscription_concours`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`),
  ADD KEY `fk_inscription_concours` (`concours_id`),
  ADD KEY `fk_inscription_candidat` (`candidat_id`),
  ADD KEY `idx_type_diplome_obtenu` (`type_diplome_obtenu`),
  ADD KEY `idx_inscription_concours_cin` (`cin`),
  ADD KEY `idx_inscription_concours_email` (`email`),
  ADD KEY `idx_inscription_concours_nom_prenom` (`nom`,`prenom`),
  ADD KEY `idx_inscription_concours_date_naissance` (`date_naissance`),
  ADD KEY `idx_inscription_concours_province_naissance` (`province_naissance`),
  ADD KEY `idx_inscription_concours_nationalite` (`nationalite`);

--
-- Index pour la table `inscription_etudiant`
--
ALTER TABLE `inscription_etudiant`
    ADD PRIMARY KEY (`id`),
  ADD KEY `student_id` (`student_id`),
  ADD KEY `filiere_id` (`filiere_id`),
  ADD KEY `fk_inscription_etudiant_annee` (`annee_universitaire_id`);

--
-- Index pour la table `livraison`
--
ALTER TABLE `livraison`
    ADD PRIMARY KEY (`id`),
  ADD KEY `fk_livraison_demande` (`demande_id`),
  ADD KEY `fk_livraison_annee` (`annee_universitaire_id`),
  ADD KEY `fk_livraison_etat` (`etat_livraison_id`);

--
-- Index pour la table `livraison_detail`
--
ALTER TABLE `livraison_detail`
    ADD PRIMARY KEY (`id`),
  ADD KEY `fk_livraisond_magasin` (`magasin_id`),
  ADD KEY `fk_livraisond_entite` (`entite_administrative_id`),
  ADD KEY `fk_livraisond_categorie` (`categorie_produit_id`),
  ADD KEY `fk_livraisond_produit` (`produit_id`),
  ADD KEY `fk_livraisond_livraison` (`livraison_id`);

--
-- Index pour la table `magasin`
--
ALTER TABLE `magasin`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `mime_document_dossier_admin`
--
ALTER TABLE `mime_document_dossier_admin`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `module`
--
ALTER TABLE `module`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`),
  ADD KEY `idx_module_filiere` (`filiere_id`),
  ADD KEY `idx_module_semestre` (`semestre_id`);

--
-- Index pour la table `note_semestre`
--
ALTER TABLE `note_semestre`
    ADD PRIMARY KEY (`id`),
  ADD KEY `idx_note_semestre_semestre` (`semestre_id`),
  ADD KEY `idx_note_semestre_student` (`student_id`),
  ADD KEY `idx_note_semestre_departement` (`departement_id`),
  ADD KEY `idx_note_semestre_filiere` (`filiere_id`),
  ADD KEY `fk_note_semestre_annee` (`annee_universitaire_id`);

--
-- Index pour la table `note_semestre_detail`
--
ALTER TABLE `note_semestre_detail`
    ADD PRIMARY KEY (`id`),
  ADD KEY `idx_note_semestre_detail_note` (`note_semestre_id`),
  ADD KEY `idx_note_semestre_detail_module` (`module_id`);

--
-- Index pour la table `paiement_demande`
--
ALTER TABLE `paiement_demande`
    ADD PRIMARY KEY (`id`),
  ADD KEY `fk_paiement_annee` (`annee_universitaire_id`),
  ADD KEY `fk_paiement_demande` (`demande_id`),
  ADD KEY `fk_paiement_type` (`type_paiement_id`),
  ADD KEY `fk_paiement_etat` (`etat_paiement_id`);

--
-- Index pour la table `presence`
--
ALTER TABLE `presence`
    ADD PRIMARY KEY (`id`),
  ADD KEY `idx_presence_date` (`date_seance`),
  ADD KEY `idx_presence_affectation_module` (`affectation_module_id`),
  ADD KEY `idx_presence_type` (`type_seance`);

--
-- Index pour la table `presence_detail`
--
ALTER TABLE `presence_detail`
    ADD PRIMARY KEY (`id`),
  ADD KEY `idx_presence_detail_presence` (`presence_id`),
  ADD KEY `idx_presence_detail_student` (`student_id`),
  ADD KEY `idx_present` (`present`);

--
-- Index pour la table `produit`
--
ALTER TABLE `produit`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`),
  ADD KEY `fk_produit_categorie` (`categorie_produit_id`);

--
-- Index pour la table `professeur`
--
ALTER TABLE `professeur`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`),
  ADD KEY `fk_professeur_grade` (`grade_id`),
  ADD KEY `fk_professeur_echellon` (`echellon_id`);

--
-- Index pour la table `reception`
--
ALTER TABLE `reception`
    ADD PRIMARY KEY (`id`),
  ADD KEY `fk_reception_demande` (`demande_id`),
  ADD KEY `fk_reception_annee` (`annee_universitaire_id`),
  ADD KEY `fk_reception_etat` (`etat_reception_id`);

--
-- Index pour la table `reception_detail`
--
ALTER TABLE `reception_detail`
    ADD PRIMARY KEY (`id`),
  ADD KEY `fk_receptiond_magasin` (`magasin_id`),
  ADD KEY `fk_receptiond_categorie` (`categorie_produit_id`),
  ADD KEY `fk_receptiond_produit` (`produit_id`),
  ADD KEY `fk_receptiond_reception` (`reception_id`);

--
-- Index pour la table `reclamation_note`
--
ALTER TABLE `reclamation_note`
    ADD PRIMARY KEY (`id`),
  ADD KEY `idx_detail` (`note_semestre_detail_id`),
  ADD KEY `idx_student` (`student_id`),
  ADD KEY `idx_statut` (`statut`);

--
-- Index pour la table `resultat_concours`
--
ALTER TABLE `resultat_concours`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `semestre`
--
ALTER TABLE `semestre`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`),
  ADD KEY `fk_semestre_annee` (`annee_universitaire_id`);

--
-- Index pour la table `sg`
--
ALTER TABLE `sg`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `stock`
--
ALTER TABLE `stock`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uk_stock_produit_magasin` (`produit_id`,`magasin_id`),
  ADD KEY `fk_stock_magasin` (`magasin_id`);

--
-- Index pour la table `student`
--
ALTER TABLE `student`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`email`);

--
-- Index pour la table `type_demande`
--
ALTER TABLE `type_demande`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `type_demande_document`
--
ALTER TABLE `type_demande_document`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uk_type_demande_document_code` (`code`);

--
-- Index pour la table `type_demande_etudiant`
--
ALTER TABLE `type_demande_etudiant`
    ADD PRIMARY KEY (`id`);

--
-- Index pour la table `type_devis_demande`
--
ALTER TABLE `type_devis_demande`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Index pour la table `type_diplome`
--
ALTER TABLE `type_diplome`
    ADD PRIMARY KEY (`id`);

--
-- Index pour la table `type_document_dossier_administratif`
--
ALTER TABLE `type_document_dossier_administratif`
    ADD PRIMARY KEY (`id`);

--
-- Index pour la table `type_grade`
--
ALTER TABLE `type_grade`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uk_type_grade_code` (`code`);

--
-- Index pour la table `type_paiement`
--
ALTER TABLE `type_paiement`
    ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- AUTO_INCREMENT pour les tables déchargées
--

--
-- AUTO_INCREMENT pour la table `admin`
--
ALTER TABLE `admin`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `affectation_module`
--
ALTER TABLE `affectation_module`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `annee_budgitaire`
--
ALTER TABLE `annee_budgitaire`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `annee_universitaire`
--
ALTER TABLE `annee_universitaire`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `avancement_type`
--
ALTER TABLE `avancement_type`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `budget_faculte`
--
ALTER TABLE `budget_faculte`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `budget_faculte_detail`
--
ALTER TABLE `budget_faculte_detail`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `candidat`
--
ALTER TABLE `candidat`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `categorie_produit`
--
ALTER TABLE `categorie_produit`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `category_document_dossier_admin`
--
ALTER TABLE `category_document_dossier_admin`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `certificat_medical`
--
ALTER TABLE `certificat_medical`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `commite_organisation_membre`
--
ALTER TABLE `commite_organisation_membre`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `concours`
--
ALTER TABLE `concours`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `concours_detail`
--
ALTER TABLE `concours_detail`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `demande`
--
ALTER TABLE `demande`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `demande_detail`
--
ALTER TABLE `demande_detail`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `demande_detail_repartition`
--
ALTER TABLE `demande_detail_repartition`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `demande_document`
--
ALTER TABLE `demande_document`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `demande_etudiant`
--
ALTER TABLE `demande_etudiant`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `departement`
--
ALTER TABLE `departement`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `devis_demande`
--
ALTER TABLE `devis_demande`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `devis_demande_detail`
--
ALTER TABLE `devis_demande_detail`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `document_dossier_admin`
--
ALTER TABLE `document_dossier_admin`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `echelle`
--
ALTER TABLE `echelle`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `echellon`
--
ALTER TABLE `echellon`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `employee`
--
ALTER TABLE `employee`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `entite_administrative`
--
ALTER TABLE `entite_administrative`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `etat_avancement`
--
ALTER TABLE `etat_avancement`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `etat_budget_faculte`
--
ALTER TABLE `etat_budget_faculte`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `etat_demande`
--
ALTER TABLE `etat_demande`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `etat_demande_document`
--
ALTER TABLE `etat_demande_document`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `etat_demande_etudiant`
--
ALTER TABLE `etat_demande_etudiant`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `etat_devis_demande`
--
ALTER TABLE `etat_devis_demande`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `etat_document_dossier_administratif`
--
ALTER TABLE `etat_document_dossier_administratif`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `etat_expression_besoin`
--
ALTER TABLE `etat_expression_besoin`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `etat_livraison`
--
ALTER TABLE `etat_livraison`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `etat_paiement`
--
ALTER TABLE `etat_paiement`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `etat_reception`
--
ALTER TABLE `etat_reception`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `etat_student`
--
ALTER TABLE `etat_student`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `expression_besoin`
--
ALTER TABLE `expression_besoin`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `expression_besoin_detail`
--
ALTER TABLE `expression_besoin_detail`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `filiere`
--
ALTER TABLE `filiere`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `fournisseur`
--
ALTER TABLE `fournisseur`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `grade`
--
ALTER TABLE `grade`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `inscription_concours`
--
ALTER TABLE `inscription_concours`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `inscription_etudiant`
--
ALTER TABLE `inscription_etudiant`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `livraison`
--
ALTER TABLE `livraison`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `livraison_detail`
--
ALTER TABLE `livraison_detail`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `magasin`
--
ALTER TABLE `magasin`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `mime_document_dossier_admin`
--
ALTER TABLE `mime_document_dossier_admin`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `module`
--
ALTER TABLE `module`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `note_semestre`
--
ALTER TABLE `note_semestre`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `note_semestre_detail`
--
ALTER TABLE `note_semestre_detail`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `paiement_demande`
--
ALTER TABLE `paiement_demande`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `presence`
--
ALTER TABLE `presence`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `presence_detail`
--
ALTER TABLE `presence_detail`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `produit`
--
ALTER TABLE `produit`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `professeur`
--
ALTER TABLE `professeur`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `reception`
--
ALTER TABLE `reception`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `reception_detail`
--
ALTER TABLE `reception_detail`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `reclamation_note`
--
ALTER TABLE `reclamation_note`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `resultat_concours`
--
ALTER TABLE `resultat_concours`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `semestre`
--
ALTER TABLE `semestre`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `sg`
--
ALTER TABLE `sg`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `stock`
--
ALTER TABLE `stock`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `student`
--
ALTER TABLE `student`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `type_demande`
--
ALTER TABLE `type_demande`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `type_demande_document`
--
ALTER TABLE `type_demande_document`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `type_demande_etudiant`
--
ALTER TABLE `type_demande_etudiant`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `type_devis_demande`
--
ALTER TABLE `type_devis_demande`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `type_diplome`
--
ALTER TABLE `type_diplome`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `type_document_dossier_administratif`
--
ALTER TABLE `type_document_dossier_administratif`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `type_grade`
--
ALTER TABLE `type_grade`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT pour la table `type_paiement`
--
ALTER TABLE `type_paiement`
    MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- Contraintes pour les tables déchargées
--

--
-- Contraintes pour la table `affectation_module`
--
ALTER TABLE `affectation_module`
    ADD CONSTRAINT `fk_affectation_employee` FOREIGN KEY (`employee_id`) REFERENCES `employee` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_affectation_filiere` FOREIGN KEY (`filiere_id`) REFERENCES `filiere` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                               ADD CONSTRAINT `fk_affectation_module` FOREIGN KEY (`module_id`) REFERENCES `module` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                                                                                                                  ADD CONSTRAINT `fk_affectation_module_annee` FOREIGN KEY (`annee_universitaire_id`) REFERENCES `annee_universitaire` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ADD CONSTRAINT `fk_affectation_semestre` FOREIGN KEY (`semestre_id`) REFERENCES `semestre` (`id`) ON UPDATE CASCADE;

--
-- Contraintes pour la table `budget_faculte`
--
ALTER TABLE `budget_faculte`
    ADD CONSTRAINT `fk_budget_faculte_annee` FOREIGN KEY (`annee_budgitaire_id`) REFERENCES `annee_budgitaire` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_budget_faculte_etat` FOREIGN KEY (`etat_budget_faculte_id`) REFERENCES `etat_budget_faculte` (`id`) ON UPDATE CASCADE;

--
-- Contraintes pour la table `budget_faculte_detail`
--
ALTER TABLE `budget_faculte_detail`
    ADD CONSTRAINT `fk_budget_detail_budget` FOREIGN KEY (`budget_faculte_id`) REFERENCES `budget_faculte` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_budget_detail_entite` FOREIGN KEY (`entite_administrative_id`) REFERENCES `entite_administrative` (`id`) ON UPDATE CASCADE;

--
-- Contraintes pour la table `commite_organisation_membre`
--
ALTER TABLE `commite_organisation_membre`
    ADD CONSTRAINT `fk_com_concours` FOREIGN KEY (`concours_id`) REFERENCES `concours` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_com_employee` FOREIGN KEY (`employee_id`) REFERENCES `employee` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Contraintes pour la table `concours`
--
ALTER TABLE `concours`
    ADD CONSTRAINT `fk_concours_chef_commite` FOREIGN KEY (`chef_commite_organisation`) REFERENCES `employee` (`id`) ON UPDATE CASCADE;

--
-- Contraintes pour la table `concours_detail`
--
ALTER TABLE `concours_detail`
    ADD CONSTRAINT `fk_concours_detail_concours` FOREIGN KEY (`concours_id`) REFERENCES `concours` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_concours_detail_type_diplome` FOREIGN KEY (`type_diplome_id`) REFERENCES `type_diplome` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Contraintes pour la table `demande`
--
ALTER TABLE `demande`
    ADD CONSTRAINT `fk_demande_annee` FOREIGN KEY (`annee_universitaire_id`) REFERENCES `annee_universitaire` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_demande_devis` FOREIGN KEY (`devis_demande_id`) REFERENCES `devis_demande` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_demande_entite` FOREIGN KEY (`entite_administrative_id`) REFERENCES `entite_administrative` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                                                                                                                                                                      ADD CONSTRAINT `fk_demande_etat` FOREIGN KEY (`etat_demande_id`) REFERENCES `etat_demande` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ADD CONSTRAINT `fk_demande_fournisseur` FOREIGN KEY (`fournisseur_id`) REFERENCES `fournisseur` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ADD CONSTRAINT `fk_demande_type` FOREIGN KEY (`type_demande_id`) REFERENCES `type_demande` (`id`) ON UPDATE CASCADE;

--
-- Contraintes pour la table `demande_detail`
--
ALTER TABLE `demande_detail`
    ADD CONSTRAINT `fk_demandd_categorie` FOREIGN KEY (`categorie_produit_id`) REFERENCES `categorie_produit` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_demandd_expression` FOREIGN KEY (`expression_besoin_id`) REFERENCES `expression_besoin` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_demandd_produit` FOREIGN KEY (`produit_id`) REFERENCES `produit` (`id`) ON UPDATE CASCADE;

--
-- Contraintes pour la table `demande_detail_repartition`
--
ALTER TABLE `demande_detail_repartition`
    ADD CONSTRAINT `fk_repart_demande_detail` FOREIGN KEY (`demande_detail_id`) REFERENCES `demande_detail` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_repart_produit` FOREIGN KEY (`produit_id`) REFERENCES `produit` (`id`) ON UPDATE CASCADE;

--
-- Contraintes pour la table `demande_document`
--
ALTER TABLE `demande_document`
    ADD CONSTRAINT `fk_demande_document_employee` FOREIGN KEY (`employee_id`) REFERENCES `employee` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_demande_document_etat` FOREIGN KEY (`etat_demande_document_id`) REFERENCES `etat_demande_document` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                                                                    ADD CONSTRAINT `fk_demande_document_type_demande_document` FOREIGN KEY (`type_demande_document_id`) REFERENCES `type_demande_document` (`id`) ON UPDATE CASCADE;

--
-- Contraintes pour la table `demande_etudiant`
--
ALTER TABLE `demande_etudiant`
    ADD CONSTRAINT `fk_etat_demande` FOREIGN KEY (`etat_id`) REFERENCES `etat_demande_etudiant` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_type_demande` FOREIGN KEY (`type_id`) REFERENCES `type_demande_etudiant` (`id`) ON DELETE CASCADE;

--
-- Contraintes pour la table `devis_demande`
--
ALTER TABLE `devis_demande`
    ADD CONSTRAINT `fk_devis_annee` FOREIGN KEY (`annee_universitaire_id`) REFERENCES `annee_universitaire` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_devis_entite` FOREIGN KEY (`entite_administrative_id`) REFERENCES `entite_administrative` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                                                 ADD CONSTRAINT `fk_devis_etat` FOREIGN KEY (`etat_devis_demande_id`) REFERENCES `etat_devis_demande` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                                                                                                                                                                    ADD CONSTRAINT `fk_devis_fournisseur` FOREIGN KEY (`fournisseur_id`) REFERENCES `fournisseur` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ADD CONSTRAINT `fk_devis_type` FOREIGN KEY (`type_devis_demande_id`) REFERENCES `type_devis_demande` (`id`) ON UPDATE CASCADE;

--
-- Contraintes pour la table `devis_demande_detail`
--
ALTER TABLE `devis_demande_detail`
    ADD CONSTRAINT `fk_devisd_categorie` FOREIGN KEY (`categorie_produit_id`) REFERENCES `categorie_produit` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_devisd_expression` FOREIGN KEY (`expression_besoin_id`) REFERENCES `expression_besoin` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_devisd_produit` FOREIGN KEY (`produit_id`) REFERENCES `produit` (`id`) ON UPDATE CASCADE;

--
-- Contraintes pour la table `document_dossier_admin`
--
ALTER TABLE `document_dossier_admin`
    ADD CONSTRAINT `fk_document_category` FOREIGN KEY (`category_id`) REFERENCES `category_document_dossier_admin` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_document_departement` FOREIGN KEY (`departement_id`) REFERENCES `departement` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_document_employee` FOREIGN KEY (`employee_id`) REFERENCES `employee` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_document_mime` FOREIGN KEY (`mime_type_id`) REFERENCES `mime_document_dossier_admin` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ADD CONSTRAINT `fk_document_uploaded_by` FOREIGN KEY (`uploaded_by`) REFERENCES `employee` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ADD CONSTRAINT `fk_document_verified_by` FOREIGN KEY (`verified_by`) REFERENCES `employee` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;

--
-- Contraintes pour la table `echelle`
--
ALTER TABLE `echelle`
    ADD CONSTRAINT `fk_echelle_grade` FOREIGN KEY (`grade_id`) REFERENCES `grade` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Contraintes pour la table `echellon`
--
ALTER TABLE `echellon`
    ADD CONSTRAINT `fk_echellon_echelle` FOREIGN KEY (`echelle_id`) REFERENCES `echelle` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_echellon_suivant` FOREIGN KEY (`echellon_suivant_id`) REFERENCES `echellon` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;

--
-- Contraintes pour la table `employee`
--
ALTER TABLE `employee`
    ADD CONSTRAINT `fk_employee_departement` FOREIGN KEY (`departement_id`) REFERENCES `departement` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_employee_echellon` FOREIGN KEY (`echellon_id`) REFERENCES `echellon` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_employee_grade` FOREIGN KEY (`grade_id`) REFERENCES `grade` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_employee_type_grade` FOREIGN KEY (`type_grade_id`) REFERENCES `type_grade` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;

--
-- Contraintes pour la table `expression_besoin`
--
ALTER TABLE `expression_besoin`
    ADD CONSTRAINT `fk_eb_annee` FOREIGN KEY (`annee_budgitaire_id`) REFERENCES `annee_budgitaire` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_eb_employee` FOREIGN KEY (`employee_id`) REFERENCES `employee` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                             ADD CONSTRAINT `fk_eb_etat` FOREIGN KEY (`etat_expression_besoin_id`) REFERENCES `etat_expression_besoin` (`id`) ON UPDATE CASCADE;

--
-- Contraintes pour la table `expression_besoin_detail`
--
ALTER TABLE `expression_besoin_detail`
    ADD CONSTRAINT `fk_ebd_categorie` FOREIGN KEY (`categorie_produit_id`) REFERENCES `categorie_produit` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_ebd_expression` FOREIGN KEY (`expression_besoin_id`) REFERENCES `expression_besoin` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Contraintes pour la table `filiere`
--
ALTER TABLE `filiere`
    ADD CONSTRAINT `fk_filiere_departement` FOREIGN KEY (`departement_id`) REFERENCES `departement` (`id`) ON UPDATE CASCADE;

--
-- Contraintes pour la table `grade`
--
ALTER TABLE `grade`
    ADD CONSTRAINT `fk_grade_type_grade` FOREIGN KEY (`type_grade_id`) REFERENCES `type_grade` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Contraintes pour la table `inscription_etudiant`
--
ALTER TABLE `inscription_etudiant`
    ADD CONSTRAINT `fk_inscription_etudiant_annee` FOREIGN KEY (`annee_universitaire_id`) REFERENCES `annee_universitaire` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `inscription_etudiant_ibfk_1` FOREIGN KEY (`student_id`) REFERENCES `student` (`id`),
  ADD CONSTRAINT `inscription_etudiant_ibfk_2` FOREIGN KEY (`filiere_id`) REFERENCES `filiere` (`id`);

--
-- Contraintes pour la table `livraison`
--
ALTER TABLE `livraison`
    ADD CONSTRAINT `fk_livraison_annee` FOREIGN KEY (`annee_universitaire_id`) REFERENCES `annee_universitaire` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_livraison_demande` FOREIGN KEY (`demande_id`) REFERENCES `demande` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                              ADD CONSTRAINT `fk_livraison_etat` FOREIGN KEY (`etat_livraison_id`) REFERENCES `etat_livraison` (`id`) ON UPDATE CASCADE;

--
-- Contraintes pour la table `livraison_detail`
--
ALTER TABLE `livraison_detail`
    ADD CONSTRAINT `fk_livraisond_categorie` FOREIGN KEY (`categorie_produit_id`) REFERENCES `categorie_produit` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_livraisond_entite` FOREIGN KEY (`entite_administrative_id`) REFERENCES `entite_administrative` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                                                           ADD CONSTRAINT `fk_livraisond_livraison` FOREIGN KEY (`livraison_id`) REFERENCES `livraison` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_livraisond_magasin` FOREIGN KEY (`magasin_id`) REFERENCES `magasin` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ADD CONSTRAINT `fk_livraisond_produit` FOREIGN KEY (`produit_id`) REFERENCES `produit` (`id`) ON UPDATE CASCADE;

--
-- Contraintes pour la table `note_semestre`
--
ALTER TABLE `note_semestre`
    ADD CONSTRAINT `fk_note_semestre_annee` FOREIGN KEY (`annee_universitaire_id`) REFERENCES `annee_universitaire` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_note_semestre_departement` FOREIGN KEY (`departement_id`) REFERENCES `departement` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                                                  ADD CONSTRAINT `fk_note_semestre_filiere` FOREIGN KEY (`filiere_id`) REFERENCES `filiere` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                                                                                                                                                          ADD CONSTRAINT `fk_note_semestre_semestre` FOREIGN KEY (`semestre_id`) REFERENCES `semestre` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ADD CONSTRAINT `fk_note_semestre_student` FOREIGN KEY (`student_id`) REFERENCES `student` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Contraintes pour la table `note_semestre_detail`
--
ALTER TABLE `note_semestre_detail`
    ADD CONSTRAINT `fk_note_semestre_detail_module` FOREIGN KEY (`module_id`) REFERENCES `module` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_note_semestre_detail_note` FOREIGN KEY (`note_semestre_id`) REFERENCES `note_semestre` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Contraintes pour la table `paiement_demande`
--
ALTER TABLE `paiement_demande`
    ADD CONSTRAINT `fk_paiement_annee` FOREIGN KEY (`annee_universitaire_id`) REFERENCES `annee_universitaire` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_paiement_demande` FOREIGN KEY (`demande_id`) REFERENCES `demande` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                            ADD CONSTRAINT `fk_paiement_etat` FOREIGN KEY (`etat_paiement_id`) REFERENCES `etat_paiement` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                                                                                                                                        ADD CONSTRAINT `fk_paiement_type` FOREIGN KEY (`type_paiement_id`) REFERENCES `type_paiement` (`id`) ON UPDATE CASCADE;

--
-- Contraintes pour la table `presence`
--
ALTER TABLE `presence`
    ADD CONSTRAINT `fk_presence_affectation_module` FOREIGN KEY (`affectation_module_id`) REFERENCES `affectation_module` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Contraintes pour la table `produit`
--
ALTER TABLE `produit`
    ADD CONSTRAINT `fk_produit_categorie` FOREIGN KEY (`categorie_produit_id`) REFERENCES `categorie_produit` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Contraintes pour la table `reception`
--
ALTER TABLE `reception`
    ADD CONSTRAINT `fk_reception_annee` FOREIGN KEY (`annee_universitaire_id`) REFERENCES `annee_universitaire` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_reception_demande` FOREIGN KEY (`demande_id`) REFERENCES `demande` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                              ADD CONSTRAINT `fk_reception_etat` FOREIGN KEY (`etat_reception_id`) REFERENCES `etat_reception` (`id`) ON UPDATE CASCADE;

--
-- Contraintes pour la table `reception_detail`
--
ALTER TABLE `reception_detail`
    ADD CONSTRAINT `fk_receptiond_categorie` FOREIGN KEY (`categorie_produit_id`) REFERENCES `categorie_produit` (`id`) ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_receptiond_magasin` FOREIGN KEY (`magasin_id`) REFERENCES `magasin` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                                ADD CONSTRAINT `fk_receptiond_produit` FOREIGN KEY (`produit_id`) REFERENCES `produit` (`id`) ON UPDATE CASCADE,
                                                                                                                                                                                                                                                                                                                                                     ADD CONSTRAINT `fk_receptiond_reception` FOREIGN KEY (`reception_id`) REFERENCES `reception` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Contraintes pour la table `semestre`
--
ALTER TABLE `semestre`
    ADD CONSTRAINT `fk_semestre_annee` FOREIGN KEY (`annee_universitaire_id`) REFERENCES `annee_universitaire` (`id`) ON UPDATE CASCADE;

--
-- Contraintes pour la table `stock`
--
ALTER TABLE `stock`
    ADD CONSTRAINT `fk_stock_magasin` FOREIGN KEY (`magasin_id`) REFERENCES `magasin` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_stock_produit` FOREIGN KEY (`produit_id`) REFERENCES `produit` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
SET FOREIGN_KEY_CHECKS=1;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
