-- phpMyAdmin SQL Dump
-- version 4.9.0.1
-- https://www.phpmyadmin.net/
--
-- Hôte : localhost
-- Généré le :  jeu. 20 nov. 2025 à 19:01
-- Version du serveur :  10.3.39-MariaDB-0+deb10u2
-- Version de PHP :  7.3.31-1~deb10u7

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
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 :  `concours_miel`
--

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

--
-- Structure de la table `beekeepers`
--

CREATE TABLE `beekeepers` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Déchargement des données de la table `beekeepers`
--

INSERT INTO `beekeepers` (`id`, `name`) VALUES
(1, 'Ravel jérome'),
(2, 'Sandie Truchard'),
(3, 'Wiliam Durand');

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

--
-- Structure de la table `categories`
--

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

--
-- Déchargement des données de la table `categories`
--

INSERT INTO `categories` (`id`, `name`, `code`) VALUES
(1, 'Acacia', 100),
(2, 'Tilleul', 200),
(3, 'Montagne Pro', 300),
(4, 'Montagne Amateur', 400),
(5, 'Plaine Amateur', 500),
(6, 'Plaine Pro', 600),
(7, 'Sarasin', 700),
(8, 'Foret', 800),
(9, 'Sapin', 900),
(10, 'Chataigner', 1000);

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

--
-- Structure de la table `criteria`
--

CREATE TABLE `criteria` (
  `id` int(11) NOT NULL,
  `label` varchar(255) NOT NULL,
  `max_points` int(11) NOT NULL DEFAULT 20
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Structure de la table `honeys`
--

CREATE TABLE `honeys` (
  `id` int(11) NOT NULL,
  `category_id` int(11) NOT NULL,
  `beekeeper_id` int(11) NOT NULL,
  `honey_number` int(11) NOT NULL,
  `name` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Déchargement des données de la table `honeys`
--

INSERT INTO `honeys` (`id`, `category_id`, `beekeeper_id`, `honey_number`, `name`) VALUES
(8, 1, 1, 101, NULL),
(9, 2, 1, 201, NULL),
(10, 5, 1, 501, NULL),
(11, 1, 2, 102, NULL),
(12, 1, 3, 103, NULL),
(13, 2, 2, 202, NULL),
(14, 2, 2, 203, NULL),
(15, 2, 3, 204, NULL),
(16, 1, 1, 104, NULL),
(17, 1, 2, 105, NULL),
(18, 1, 3, 106, NULL);

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

--
-- Structure de la table `jurors`
--

CREATE TABLE `jurors` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `table_id` int(11) NOT NULL DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Déchargement des données de la table `jurors`
--

INSERT INTO `jurors` (`id`, `name`, `table_id`) VALUES
(1, 'alain ducas', 1),
(2, 'Jean nemard', 1),
(3, 'Eric antoine', 1),
(4, 'sylvie Rajtournbrak', 1),
(5, 'test1', 2),
(6, 'Test2', 2),
(7, 'test3', 2),
(8, 'test4', 2);

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

--
-- Structure de la table `juror_scores`
--

CREATE TABLE `juror_scores` (
  `id` int(11) NOT NULL,
  `juror_id` int(11) NOT NULL,
  `honey_id` int(11) NOT NULL,
  `table_id` int(11) NOT NULL,
  `total_score` decimal(6,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Structure de la table `juror_score_details`
--

CREATE TABLE `juror_score_details` (
  `id` int(11) NOT NULL,
  `juror_score_id` int(11) NOT NULL,
  `criterion_id` int(11) NOT NULL,
  `score` decimal(6,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Structure de la table `settings`
--

CREATE TABLE `settings` (
  `id` int(11) NOT NULL,
  `skey` varchar(255) NOT NULL,
  `svalue` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Déchargement des données de la table `settings`
--

INSERT INTO `settings` (`id`, `skey`, `svalue`) VALUES
(1, 'admin_password', '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918');

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

--
-- Structure de la table `tables`
--

CREATE TABLE `tables` (
  `id` int(11) NOT NULL,
  `name` varchar(50) NOT NULL,
  `category_id` int(11) NOT NULL,
  `max_miels` int(11) NOT NULL DEFAULT 8
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Déchargement des données de la table `tables`
--

INSERT INTO `tables` (`id`, `name`, `category_id`, `max_miels`) VALUES
(1, '1', 1, 8),
(2, '2', 2, 8),
(3, '3', 3, 8);

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

--
-- Structure de la table `table_assignments`
--

CREATE TABLE `table_assignments` (
  `id` int(11) NOT NULL,
  `table_id` int(11) NOT NULL,
  `honey_id` int(11) NOT NULL,
  `slot` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Structure de la table `tasting_tables`
--

CREATE TABLE `tasting_tables` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `round` enum('initial','quart','demi','finale') NOT NULL DEFAULT 'initial'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

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

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

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

--
-- Index pour la table `honeys`
--
ALTER TABLE `honeys`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `honey_number` (`honey_number`),
  ADD KEY `category_id` (`category_id`),
  ADD KEY `beekeeper_id` (`beekeeper_id`);

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

--
-- Index pour la table `juror_scores`
--
ALTER TABLE `juror_scores`
  ADD PRIMARY KEY (`id`),
  ADD KEY `juror_id` (`juror_id`),
  ADD KEY `honey_id` (`honey_id`),
  ADD KEY `table_id` (`table_id`);

--
-- Index pour la table `juror_score_details`
--
ALTER TABLE `juror_score_details`
  ADD PRIMARY KEY (`id`),
  ADD KEY `juror_score_id` (`juror_score_id`),
  ADD KEY `criterion_id` (`criterion_id`);

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

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

--
-- Index pour la table `table_assignments`
--
ALTER TABLE `table_assignments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `table_id` (`table_id`),
  ADD KEY `honey_id` (`honey_id`);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

--
-- Contraintes pour la table `honeys`
--
ALTER TABLE `honeys`
  ADD CONSTRAINT `honeys_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `honeys_ibfk_2` FOREIGN KEY (`beekeeper_id`) REFERENCES `beekeepers` (`id`) ON DELETE CASCADE;

--
-- Contraintes pour la table `juror_scores`
--
ALTER TABLE `juror_scores`
  ADD CONSTRAINT `juror_scores_ibfk_1` FOREIGN KEY (`juror_id`) REFERENCES `jurors` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `juror_scores_ibfk_2` FOREIGN KEY (`honey_id`) REFERENCES `honeys` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `juror_scores_ibfk_3` FOREIGN KEY (`table_id`) REFERENCES `tasting_tables` (`id`) ON DELETE CASCADE;

--
-- Contraintes pour la table `juror_score_details`
--
ALTER TABLE `juror_score_details`
  ADD CONSTRAINT `juror_score_details_ibfk_1` FOREIGN KEY (`juror_score_id`) REFERENCES `juror_scores` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `juror_score_details_ibfk_2` FOREIGN KEY (`criterion_id`) REFERENCES `criteria` (`id`) ON DELETE CASCADE;

--
-- Contraintes pour la table `table_assignments`
--
ALTER TABLE `table_assignments`
  ADD CONSTRAINT `table_assignments_ibfk_1` FOREIGN KEY (`table_id`) REFERENCES `tasting_tables` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `table_assignments_ibfk_2` FOREIGN KEY (`honey_id`) REFERENCES `honeys` (`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 */;
