
DROP TABLE IF EXISTS `quizz`;
CREATE TABLE `quizz` (
  `PK_quizz_id` int NOT NULL,
  `libelle_quizz` varchar(192) NOT NULL,
  `FK_event_id` int NOT NULL,
  `actif_quizz` int NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

DROP TABLE IF EXISTS `quizz_question`;
CREATE TABLE `quizz_question` (
  `PK_quizz_question_id` int NOT NULL,
  `FK_quizz_id` int NOT NULL,
  `texte_quizz_question` text NOT NULL,
  `explication_quizz_question` text NOT NULL,
  `libelle_quizz_question` varchar(192) NOT NULL,
  `numero_quizz_question` int NOT NULL,
  `coefficient` int NOT NULL DEFAULT '1',
  `actif_quizz_question` int NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

DROP TABLE IF EXISTS `quizz_question_users`;
CREATE TABLE `quizz_question_users` (
  `FK_quizz_question_id` int NOT NULL,
  `FK_users_id` int NOT NULL,
  `FK_quizz_reponse_id` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


DROP TABLE IF EXISTS `quizz_reponse`;
CREATE TABLE `quizz_reponse` (
  `PK_quizz_reponse_id` int NOT NULL,
  `FK_quizz_question_id` int NOT NULL,
  `texte_quizz_reponse` text NOT NULL,
  `libelle_quizz_reponse` varchar(192) NOT NULL,
  `istrue_quizz_reponse` tinyint(1) NOT NULL,
  `numero_quizz_reponse` int NOT NULL,
  `actif_quizz_reponse` int NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

ALTER TABLE `quizz`
  ADD PRIMARY KEY (`PK_quizz_id`),
  ADD KEY `FK_event_id` (`FK_event_id`);

ALTER TABLE `quizz_question`
  ADD PRIMARY KEY (`PK_quizz_question_id`),
  ADD KEY `FK_quizz_id` (`FK_quizz_id`);

ALTER TABLE `quizz_question_users`
  ADD KEY `FK_quizz_question_id` (`FK_quizz_question_id`),
  ADD KEY `FK_users_id` (`FK_users_id`),
  ADD KEY `FK_quizz_reponse_id` (`FK_quizz_reponse_id`);

ALTER TABLE `quizz_reponse`
  ADD PRIMARY KEY (`PK_quizz_reponse_id`);

ALTER TABLE `quizz`
  MODIFY `PK_quizz_id` int NOT NULL AUTO_INCREMENT;

ALTER TABLE `quizz_question`
  MODIFY `PK_quizz_question_id` int NOT NULL AUTO_INCREMENT;

ALTER TABLE `quizz_reponse`
  MODIFY `PK_quizz_reponse_id` int NOT NULL AUTO_INCREMENT;
COMMIT;
