-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Hôte : localhost
-- Généré le : sam. 01 août 2026 à 11:12
-- Version du serveur : 10.4.28-MariaDB
-- Version de PHP : 8.2.4

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 : `tc_quiz_local`
--

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

--
-- Structure de la table `acceptation`
--

CREATE TABLE `acceptation` (
  `id` int(11) NOT NULL,
  `code_membre` varchar(20) NOT NULL,
  `version` int(11) NOT NULL,
  `titre` varchar(200) NOT NULL,
  `texte_accepte` mediumtext NOT NULL,
  `accepte_le` datetime NOT NULL DEFAULT current_timestamp(),
  `ip` varchar(45) DEFAULT NULL,
  `user_agent` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- Erreur de lecture des données pour la table tc_quiz_local.acceptation : #1064 - Erreur de syntaxe près de &#039;FROM `tc_quiz_local`.`acceptation`&#039; à la ligne 1

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

--
-- Structure de la table `chapitre`
--

CREATE TABLE `chapitre` (
  `id` int(11) NOT NULL,
  `pays` char(2) NOT NULL DEFAULT 'FR',
  `langue` char(2) NOT NULL DEFAULT 'fr',
  `niveau_id` varchar(4) NOT NULL,
  `matiere_id` varchar(60) NOT NULL,
  `code` varchar(80) NOT NULL,
  `nom` varchar(200) NOT NULL,
  `competence` text DEFAULT NULL,
  `perimetre` text DEFAULT NULL,
  `connaissances` text DEFAULT NULL,
  `exclusions` text DEFAULT NULL,
  `curriculum_ref` varchar(255) DEFAULT NULL,
  `official` tinyint(1) NOT NULL DEFAULT 1,
  `ordre` int(11) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- Erreur de lecture des données pour la table tc_quiz_local.chapitre : #1064 - Erreur de syntaxe près de &#039;FROM `tc_quiz_local`.`chapitre`&#039; à la ligne 1

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

--
-- Structure de la table `choix`
--

CREATE TABLE `choix` (
  `id` int(11) NOT NULL,
  `question_id` int(11) NOT NULL,
  `texte` varchar(500) NOT NULL,
  `est_correct` tinyint(1) NOT NULL DEFAULT 0,
  `position` tinyint(4) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- Erreur de lecture des données pour la table tc_quiz_local.choix : #1064 - Erreur de syntaxe près de &#039;FROM `tc_quiz_local`.`choix`&#039; à la ligne 1

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

--
-- Structure de la table `domaine`
--

CREATE TABLE `domaine` (
  `code` varchar(4) NOT NULL,
  `type` varchar(20) NOT NULL DEFAULT 'general',
  `ordre` tinyint(4) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- Erreur de lecture des données pour la table tc_quiz_local.domaine : #1064 - Erreur de syntaxe près de &#039;FROM `tc_quiz_local`.`domaine`&#039; à la ligne 1

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

--
-- Structure de la table `domaine_i18n`
--

CREATE TABLE `domaine_i18n` (
  `domaine_code` varchar(4) NOT NULL,
  `langue` char(2) NOT NULL,
  `nom` varchar(120) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- Erreur de lecture des données pour la table tc_quiz_local.domaine_i18n : #1064 - Erreur de syntaxe près de &#039;FROM `tc_quiz_local`.`domaine_i18n`&#039; à la ligne 1

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

--
-- Structure de la table `matiere`
--

CREATE TABLE `matiere` (
  `id` varchar(60) NOT NULL,
  `niveau_id` varchar(4) NOT NULL,
  `nom` varchar(160) NOT NULL,
  `optional` tinyint(1) NOT NULL DEFAULT 0,
  `domaine_code` varchar(4) DEFAULT NULL,
  `code2` varchar(3) DEFAULT NULL,
  `ordre` smallint(6) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- Erreur de lecture des données pour la table tc_quiz_local.matiere : #1064 - Erreur de syntaxe près de &#039;FROM `tc_quiz_local`.`matiere`&#039; à la ligne 1

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

--
-- Structure de la table `matiere_i18n`
--

CREATE TABLE `matiere_i18n` (
  `matiere_id` varchar(60) NOT NULL,
  `niveau_id` varchar(4) NOT NULL,
  `langue` char(2) NOT NULL,
  `nom` varchar(160) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- Erreur de lecture des données pour la table tc_quiz_local.matiere_i18n : #1064 - Erreur de syntaxe près de &#039;FROM `tc_quiz_local`.`matiere_i18n`&#039; à la ligne 1

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

--
-- Structure de la table `media`
--

CREATE TABLE `media` (
  `id` int(10) UNSIGNED NOT NULL,
  `code_question` varchar(40) NOT NULL,
  `categorie` enum('image','audio','video','document','autre') NOT NULL DEFAULT 'autre',
  `type` varchar(100) NOT NULL,
  `nom_original` varchar(255) NOT NULL,
  `chemin` varchar(255) NOT NULL,
  `chemin_leger` varchar(255) DEFAULT NULL,
  `largeur` int(11) DEFAULT NULL,
  `hauteur` int(11) DEFAULT NULL,
  `taille` int(10) UNSIGNED DEFAULT NULL,
  `legende` varchar(255) DEFAULT NULL,
  `ordre` smallint(6) NOT NULL DEFAULT 0,
  `cree_par` varchar(10) DEFAULT NULL,
  `cree_le` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- Erreur de lecture des données pour la table tc_quiz_local.media : #1064 - Erreur de syntaxe près de &#039;FROM `tc_quiz_local`.`media`&#039; à la ligne 1

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

--
-- Structure de la table `membre`
--

CREATE TABLE `membre` (
  `id` int(10) UNSIGNED NOT NULL,
  `code` varchar(10) NOT NULL,
  `courriel` varchar(190) NOT NULL,
  `prenom` varchar(100) NOT NULL DEFAULT '',
  `nom` varchar(100) NOT NULL DEFAULT '',
  `presentation` text DEFAULT NULL,
  `photo` varchar(255) DEFAULT NULL,
  `statut` char(1) NOT NULL DEFAULT 'M',
  `mdp_hash` varchar(255) NOT NULL,
  `login_token` varchar(64) DEFAULT NULL,
  `cree_le` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Erreur de lecture des données pour la table tc_quiz_local.membre : #1064 - Erreur de syntaxe près de &#039;FROM `tc_quiz_local`.`membre`&#039; à la ligne 1

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

--
-- Structure de la table `membre_acces`
--

CREATE TABLE `membre_acces` (
  `membre_id` int(10) UNSIGNED NOT NULL,
  `niveau_id` varchar(8) NOT NULL,
  `matiere_id` varchar(64) NOT NULL,
  `responsable` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- Erreur de lecture des données pour la table tc_quiz_local.membre_acces : #1064 - Erreur de syntaxe près de &#039;FROM `tc_quiz_local`.`membre_acces`&#039; à la ligne 1

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

--
-- Structure de la table `niveau`
--

CREATE TABLE `niveau` (
  `id` varchar(4) NOT NULL,
  `grade` varchar(20) NOT NULL,
  `ordre` tinyint(4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- Erreur de lecture des données pour la table tc_quiz_local.niveau : #1064 - Erreur de syntaxe près de &#039;FROM `tc_quiz_local`.`niveau`&#039; à la ligne 1

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

--
-- Structure de la table `niveau_i18n`
--

CREATE TABLE `niveau_i18n` (
  `niveau_id` varchar(4) NOT NULL,
  `langue` char(2) NOT NULL,
  `libelle` varchar(80) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- Erreur de lecture des données pour la table tc_quiz_local.niveau_i18n : #1064 - Erreur de syntaxe près de &#039;FROM `tc_quiz_local`.`niveau_i18n`&#039; à la ligne 1

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

--
-- Structure de la table `notification`
--

CREATE TABLE `notification` (
  `id` int(10) UNSIGNED NOT NULL,
  `membre_code` varchar(10) NOT NULL,
  `code_question` varchar(40) DEFAULT NULL,
  `texte` varchar(255) NOT NULL,
  `lu` tinyint(1) NOT NULL DEFAULT 0,
  `cree_le` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- Erreur de lecture des données pour la table tc_quiz_local.notification : #1064 - Erreur de syntaxe près de &#039;FROM `tc_quiz_local`.`notification`&#039; à la ligne 1

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

--
-- Structure de la table `objectif_chapitre`
--

CREATE TABLE `objectif_chapitre` (
  `objectif_id` int(11) NOT NULL,
  `chapitre_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- Erreur de lecture des données pour la table tc_quiz_local.objectif_chapitre : #1064 - Erreur de syntaxe près de &#039;FROM `tc_quiz_local`.`objectif_chapitre`&#039; à la ligne 1

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

--
-- Structure de la table `objectif_niveau`
--

CREATE TABLE `objectif_niveau` (
  `id` int(11) NOT NULL,
  `pays` char(2) NOT NULL DEFAULT 'FR',
  `matiere_id` varchar(60) NOT NULL,
  `niveau_id` varchar(4) NOT NULL,
  `ordre` int(11) NOT NULL DEFAULT 0,
  `code` varchar(80) DEFAULT NULL,
  `libelle` varchar(400) NOT NULL,
  `ref_programme` varchar(255) DEFAULT NULL,
  `actif` tinyint(1) NOT NULL DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- Erreur de lecture des données pour la table tc_quiz_local.objectif_niveau : #1064 - Erreur de syntaxe près de &#039;FROM `tc_quiz_local`.`objectif_niveau`&#039; à la ligne 1

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

--
-- Structure de la table `question`
--

CREATE TABLE `question` (
  `id` int(11) NOT NULL,
  `chapitre_id` int(11) NOT NULL,
  `type` enum('qcm','numeric') NOT NULL DEFAULT 'qcm',
  `enonce` text NOT NULL,
  `difficulte` tinyint(4) DEFAULT 1,
  `explication` text DEFAULT NULL,
  `num_value` decimal(18,6) DEFAULT NULL,
  `num_tolerance` decimal(18,6) DEFAULT 0.000000,
  `num_unit` varchar(40) DEFAULT NULL,
  `statut` enum('draft','in_review','validated','rejected') NOT NULL DEFAULT 'draft',
  `valide_par` varchar(120) DEFAULT NULL,
  `valide_le` datetime DEFAULT NULL,
  `note_qa` text DEFAULT NULL,
  `source` varchar(120) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `motif_rejet` text DEFAULT NULL,
  `ref` varchar(40) DEFAULT NULL,
  `version` int(11) NOT NULL DEFAULT 1,
  `courante` tinyint(1) NOT NULL DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- Erreur de lecture des données pour la table tc_quiz_local.question : #1064 - Erreur de syntaxe près de &#039;FROM `tc_quiz_local`.`question`&#039; à la ligne 1

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

--
-- Structure de la table `registre`
--

CREATE TABLE `registre` (
  `id` int(10) UNSIGNED NOT NULL,
  `code_question` varchar(30) DEFAULT NULL,
  `code_membre` varchar(10) DEFAULT NULL,
  `action` varchar(20) NOT NULL,
  `motif` text DEFAULT NULL,
  `cree_le` datetime NOT NULL DEFAULT current_timestamp(),
  `version` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Erreur de lecture des données pour la table tc_quiz_local.registre : #1064 - Erreur de syntaxe près de &#039;FROM `tc_quiz_local`.`registre`&#039; à la ligne 1

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

--
-- Structure de la table `vocabulaire`
--

CREATE TABLE `vocabulaire` (
  `cle` varchar(80) NOT NULL,
  `langue` char(2) NOT NULL,
  `texte` varchar(500) NOT NULL,
  `portee` enum('atelier','app','commun') NOT NULL DEFAULT 'commun',
  `commentaire` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- Erreur de lecture des données pour la table tc_quiz_local.vocabulaire : #1064 - Erreur de syntaxe près de &#039;FROM `tc_quiz_local`.`vocabulaire`&#039; à la ligne 1

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

--
-- Index pour la table `acceptation`
--
ALTER TABLE `acceptation`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_acc` (`code_membre`,`version`),
  ADD KEY `idx_membre` (`code_membre`);

--
-- Index pour la table `chapitre`
--
ALTER TABLE `chapitre`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_chap` (`pays`,`niveau_id`,`matiere_id`,`code`),
  ADD KEY `matiere_id` (`matiere_id`,`niveau_id`);

--
-- Index pour la table `choix`
--
ALTER TABLE `choix`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_q` (`question_id`);

--
-- Index pour la table `domaine`
--
ALTER TABLE `domaine`
  ADD PRIMARY KEY (`code`);

--
-- Index pour la table `domaine_i18n`
--
ALTER TABLE `domaine_i18n`
  ADD PRIMARY KEY (`domaine_code`,`langue`);

--
-- Index pour la table `matiere`
--
ALTER TABLE `matiere`
  ADD PRIMARY KEY (`id`,`niveau_id`),
  ADD KEY `niveau_id` (`niveau_id`),
  ADD KEY `idx_domaine` (`domaine_code`);

--
-- Index pour la table `matiere_i18n`
--
ALTER TABLE `matiere_i18n`
  ADD PRIMARY KEY (`matiere_id`,`niveau_id`,`langue`);

--
-- Index pour la table `media`
--
ALTER TABLE `media`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_q` (`code_question`);

--
-- Index pour la table `membre`
--
ALTER TABLE `membre`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uk_code` (`code`),
  ADD UNIQUE KEY `uk_courriel` (`courriel`);

--
-- Index pour la table `membre_acces`
--
ALTER TABLE `membre_acces`
  ADD PRIMARY KEY (`membre_id`,`niveau_id`,`matiere_id`),
  ADD KEY `idx_membre` (`membre_id`);

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

--
-- Index pour la table `niveau_i18n`
--
ALTER TABLE `niveau_i18n`
  ADD PRIMARY KEY (`niveau_id`,`langue`);

--
-- Index pour la table `notification`
--
ALTER TABLE `notification`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_dest` (`membre_code`,`lu`),
  ADD KEY `idx_date` (`cree_le`);

--
-- Index pour la table `objectif_chapitre`
--
ALTER TABLE `objectif_chapitre`
  ADD PRIMARY KEY (`objectif_id`,`chapitre_id`),
  ADD KEY `chap` (`chapitre_id`);

--
-- Index pour la table `objectif_niveau`
--
ALTER TABLE `objectif_niveau`
  ADD PRIMARY KEY (`id`),
  ADD KEY `mat` (`matiere_id`,`niveau_id`);

--
-- Index pour la table `question`
--
ALTER TABLE `question`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_chap` (`chapitre_id`),
  ADD KEY `idx_statut` (`statut`),
  ADD KEY `idx_ref` (`ref`),
  ADD KEY `idx_courante` (`courante`);

--
-- Index pour la table `registre`
--
ALTER TABLE `registre`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_question` (`code_question`),
  ADD KEY `idx_membre` (`code_membre`),
  ADD KEY `idx_date` (`cree_le`);

--
-- Index pour la table `vocabulaire`
--
ALTER TABLE `vocabulaire`
  ADD PRIMARY KEY (`cle`,`langue`),
  ADD KEY `idx_portee` (`portee`);

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

--
-- AUTO_INCREMENT pour la table `acceptation`
--
ALTER TABLE `acceptation`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT pour la table `chapitre`
--
ALTER TABLE `chapitre`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2735;

--
-- AUTO_INCREMENT pour la table `choix`
--
ALTER TABLE `choix`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=29867;

--
-- AUTO_INCREMENT pour la table `media`
--
ALTER TABLE `media`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT pour la table `membre`
--
ALTER TABLE `membre`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT pour la table `notification`
--
ALTER TABLE `notification`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

--
-- AUTO_INCREMENT pour la table `objectif_niveau`
--
ALTER TABLE `objectif_niveau`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1122;

--
-- AUTO_INCREMENT pour la table `question`
--
ALTER TABLE `question`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5565;

--
-- AUTO_INCREMENT pour la table `registre`
--
ALTER TABLE `registre`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3356;

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

--
-- Contraintes pour la table `chapitre`
--
ALTER TABLE `chapitre`
  ADD CONSTRAINT `chapitre_ibfk_1` FOREIGN KEY (`matiere_id`,`niveau_id`) REFERENCES `matiere` (`id`, `niveau_id`);

--
-- Contraintes pour la table `choix`
--
ALTER TABLE `choix`
  ADD CONSTRAINT `choix_ibfk_1` FOREIGN KEY (`question_id`) REFERENCES `question` (`id`) ON DELETE CASCADE;

--
-- Contraintes pour la table `matiere`
--
ALTER TABLE `matiere`
  ADD CONSTRAINT `matiere_ibfk_1` FOREIGN KEY (`niveau_id`) REFERENCES `niveau` (`id`);

--
-- Contraintes pour la table `objectif_chapitre`
--
ALTER TABLE `objectif_chapitre`
  ADD CONSTRAINT `oc_ibfk_1` FOREIGN KEY (`objectif_id`) REFERENCES `objectif_niveau` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `oc_ibfk_2` FOREIGN KEY (`chapitre_id`) REFERENCES `chapitre` (`id`) ON DELETE CASCADE;

--
-- Contraintes pour la table `objectif_niveau`
--
ALTER TABLE `objectif_niveau`
  ADD CONSTRAINT `objectif_ibfk_1` FOREIGN KEY (`matiere_id`,`niveau_id`) REFERENCES `matiere` (`id`, `niveau_id`) ON DELETE CASCADE;

--
-- Contraintes pour la table `question`
--
ALTER TABLE `question`
  ADD CONSTRAINT `question_ibfk_1` FOREIGN KEY (`chapitre_id`) REFERENCES `chapitre` (`id`) ON DELETE CASCADE;
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 */;
