Files
dietetique/sql/dietetique_v24.sql
T
2024-04-07 00:59:45 -04:00

1015 lines
27 KiB
SQL

-- phpMyAdmin SQL Dump
-- version 4.8.3
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Dec 07, 2018 at 02:15 AM
-- Server version: 10.1.37-MariaDB
-- PHP Version: 7.1.24
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 */;
--
-- Database: `dietetique_2`
--
DELIMITER $$
--
-- Procedures
--
CREATE PROCEDURE `updatelimiteproduit` (IN `p_id` INT, IN `p_limite` INT) begin
DECLARE done INT DEFAULT FALSE;
declare v_compte int;
declare v_quantite int;
declare c_panier cursor for select id_compte, quantite from panier where id_produit = p_id;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
open c_panier;
panier_loop: loop
fetch c_panier into v_compte, v_quantite;
IF done THEN
LEAVE panier_loop;
END IF;
if v_quantite > p_limite then
update panier set quantite = p_limite where id_compte = v_compte and id_produit = p_id;
end if;
end loop;
close c_panier;
end$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Table structure for table `access_token`
--
CREATE TABLE `access_token` (
`id` int(11) NOT NULL,
`id_compte` int(11) NOT NULL,
`selector` char(16) COLLATE utf8_bin NOT NULL,
`token` char(64) COLLATE utf8_bin NOT NULL,
`expires` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `categorie`
--
CREATE TABLE `categorie` (
`id_categorie` int(11) NOT NULL,
`nom` varchar(255) COLLATE utf8_bin NOT NULL,
`actif` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=COMPACT;
--
-- Dumping data for table `categorie`
--
INSERT INTO `categorie` (`id_categorie`, `nom`, `actif`) VALUES
(1, 'Fruits et Légumes', 1),
(2, 'Viandes', 1),
(3, 'Divers', 1);
-- --------------------------------------------------------
--
-- Table structure for table `commandes`
--
CREATE TABLE `commandes` (
`id_commande` int(11) NOT NULL,
`id_compte` int(11) NOT NULL,
`numero_commande` varchar(1024) COLLATE utf8_bin NOT NULL,
`date` datetime NOT NULL,
`status` char(1) COLLATE utf8_bin NOT NULL,
`prix_total` decimal(20,2) NOT NULL,
`trace_paiement` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=COMPACT;
--
-- Triggers `commandes`
--
DELIMITER $$
CREATE TRIGGER `tai_commandes` AFTER INSERT ON `commandes` FOR EACH ROW begin
DECLARE done INT DEFAULT FALSE;
declare v_nom varchar(255);
declare v_prenom varchar(255);
declare v_courriel varchar(255);
declare v_produit int;
declare v_quantite decimal;
declare c_panier cursor for select id_produit, quantite from panier where panier.id_compte = new.id_compte;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
select c.nom, c.prenom, c.courriel into v_nom, v_prenom, v_courriel
from comptes c
where c.id_compte = new.id_compte;
insert into historiquecommande
values (null,
new.id_commande,
new.id_compte,
new.numero_commande,
v_nom,
v_prenom,
v_courriel,
new.date,
new.status,
new.prix_total,
new.trace_paiement);
#commandesproduit
if new.status = 'P'
then
open c_panier;
panier_loop: loop
fetch c_panier
into v_produit, v_quantite;
IF done
THEN
LEAVE panier_loop;
END IF;
insert into commandesproduits values (new.id_commande, v_produit, v_quantite);
end loop;
close c_panier;
delete from panier where panier.id_compte = new.id_compte;
end if;
end
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `tau_commandes` AFTER UPDATE ON `commandes` FOR EACH ROW begin
DECLARE done INT DEFAULT FALSE;
declare v_produit int;
declare v_quantite decimal;
declare c_panier cursor for select id_produit, quantite from panier where panier.id_compte = new.id_compte;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
if old.status = 'N' then
open c_panier;
panier_loop: loop
fetch c_panier into v_produit, v_quantite;
IF done THEN
LEAVE panier_loop;
END IF;
insert into commandesproduits values (new.id_commande, v_produit, v_quantite);
end loop;
close c_panier;
delete from panier where panier.id_compte = new.id_compte;
end if;
end
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `tbd_commandes` BEFORE DELETE ON `commandes` FOR EACH ROW begin
delete from commandesproduits where commandesproduits.id_commande = old.id_commande;
end
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `tbi_commandes` BEFORE INSERT ON `commandes` FOR EACH ROW begin
set new.date = now();
end
$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Table structure for table `commandesproduits`
--
CREATE TABLE `commandesproduits` (
`id_commande` int(11) NOT NULL,
`id_produit` int(11) NOT NULL,
`quantite` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Triggers `commandesproduits`
--
DELIMITER $$
CREATE TRIGGER `tai_commandesproduit` AFTER INSERT ON `commandesproduits` FOR EACH ROW begin
declare v_nom varchar(255);
declare v_description varchar(1024);
declare v_marque varchar(255);
declare v_achatmin varchar(255);
declare v_economie varchar(255);
declare v_unite varchar(255);
declare v_format varchar(255);
declare v_prix decimal(20,2);
declare v_fraisfixe decimal(20,2);
declare v_limite varchar(255);
declare v_categorie varchar(255);
select p.nom,
p.description,
p.marque,
p.achat_minimum,
p.economie,
p.unite,
f2.nom,
p2.prix,
p.frais_fixe,
p.limite_achat,
c2.nom into v_nom, v_description, v_marque, v_achatmin, v_economie, v_unite, v_format, v_prix, v_fraisfixe, v_limite, v_categorie
from produits p
inner join format f2 on p.format = f2.id_format
inner join categorie c2 on p.categorie = c2.id_categorie
inner join produitsfournisseurs p2 on p.id_produit = p2.id_produit
where p.id_produit = new.id_produit;
insert into historiquecommandeproduit
values ((select id_historique from historiquecommande hc where hc.id_commande = new.id_commande),
new.id_produit,
v_nom,
v_description,
v_marque,
v_achatmin,
v_limite,
v_economie,
v_unite,
v_format,
v_prix,
v_fraisfixe,
v_categorie,
new.quantite);
end
$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Table structure for table `commentaires`
--
CREATE TABLE `commentaires` (
`id_commentaire` int(11) NOT NULL,
`id_compte` int(11) NOT NULL,
`date` datetime NOT NULL,
`commentaire` varchar(2048) COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `comptes`
--
CREATE TABLE `comptes` (
`id_compte` int(11) NOT NULL,
`courriel` varchar(255) COLLATE utf8_bin NOT NULL,
`password` varchar(255) COLLATE utf8_bin NOT NULL,
`nom` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`prenom` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`telephone` varchar(30) COLLATE utf8_bin DEFAULT NULL,
`poste` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`type` char(1) COLLATE utf8_bin NOT NULL DEFAULT 'U'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Dumping data for table `comptes`
--
INSERT INTO `comptes` (`id_compte`, `courriel`, `password`, `nom`, `prenom`, `telephone`, `poste`, `type`) VALUES
(16, '[email protected]', '$2y$10$.mB/c0ntseE6/FtaFkZ3n.rze9Bt7vEGi7A0sHtZZnCV3BG1yye6K', 'Admin', 'Admin', '8193761721', '', 'A'),
(18, '[email protected]', '$2y$10$QYRDoIvq39s.m/6O4BMxIecMingyCTMGsd1V49ct2lL0QdMIUDLHm', 'Robert', 'Anthony', '8199447206', '', 'E');
--
-- Triggers `comptes`
--
DELIMITER $$
CREATE TRIGGER `tbd_comptes` BEFORE DELETE ON `comptes` FOR EACH ROW delete from panier where panier.id_compte = OLD.id_compte
$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Table structure for table `configuration`
--
CREATE TABLE `configuration` (
`cle` varchar(255) COLLATE utf8_bin NOT NULL,
`valeur` varchar(4096) COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Dumping data for table `configuration`
--
INSERT INTO `configuration` (`cle`, `valeur`) VALUES
('fonctionnement', 'Voici notre fonctionnement'),
('mission', 'Salut, ceci est notre mission');
-- --------------------------------------------------------
--
-- Table structure for table `datescommandes`
--
CREATE TABLE `datescommandes` (
`id_periode` int(11) NOT NULL,
`date_debut` datetime NOT NULL,
`date_fin` datetime NOT NULL,
`nom` varchar(255) COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Dumping data for table `datescommandes`
--
INSERT INTO `datescommandes` (`id_periode`, `date_debut`, `date_fin`, `nom`) VALUES
(1, '2018-11-24 00:00:00', '2019-03-10 00:00:00', 'test'),
(2, '2018-12-01 00:00:00', '2018-12-01 00:00:00', 'test2'),
(3, '2018-12-06 00:00:00', '2018-12-07 00:00:00', 'commande');
-- --------------------------------------------------------
--
-- Table structure for table `datespaiements`
--
CREATE TABLE `datespaiements` (
`date_debut` datetime NOT NULL,
`date_fin` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `events`
--
CREATE TABLE `events` (
`id` int(11) NOT NULL,
`title` varchar(255) NOT NULL,
`color` varchar(7) DEFAULT NULL,
`start` datetime NOT NULL,
`end` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `events`
--
INSERT INTO `events` (`id`, `title`, `color`, `start`, `end`) VALUES
(16, 'test2', '#0071c5', '2018-12-01 00:00:00', '2018-12-01 00:00:00'),
(18, 'commande', '#0071c5', '2018-12-06 00:00:00', '2018-12-07 00:00:00');
--
-- Triggers `events`
--
DELIMITER $$
CREATE TRIGGER `tad` AFTER DELETE ON `events` FOR EACH ROW begin
delete from datescommandes where id_periode = old.id;
end
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `tai_events` AFTER INSERT ON `events` FOR EACH ROW begin
if new.color = '#0071c5' then
insert into datescommandes values(new.id, new.start, new.end, new.title);
end if;
end
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `tau_events` AFTER UPDATE ON `events` FOR EACH ROW begin
declare nb int;
if new.color = '#0071c5'
then
select count(*) into nb from datescommandes where date_debut = old.start
and date_fin = old.end;
if nb > 0
then
update datescommandes
set date_debut = new.start,
date_fin = new.end,
nom = new.title
where date_debut = old.start
and date_fin = old.end;
else
insert into datescommandes values (null, new.start, new.end, new.title);
end if;
end if;
end
$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Table structure for table `format`
--
CREATE TABLE `format` (
`id_format` int(11) NOT NULL,
`nom` varchar(255) COLLATE utf8_bin NOT NULL,
`actif` tinyint(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Dumping data for table `format`
--
INSERT INTO `format` (`id_format`, `nom`, `actif`) VALUES
(1, 'kg', 1);
-- --------------------------------------------------------
--
-- Table structure for table `fournisseurs`
--
CREATE TABLE `fournisseurs` (
`id_fournisseur` int(11) NOT NULL,
`nom` varchar(255) COLLATE utf8_bin NOT NULL,
`succursale` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`nom_contact` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`role` varchar(255) COLLATE utf8_bin NOT NULL,
`adresse` varchar(1024) COLLATE utf8_bin DEFAULT NULL,
`ville` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`code_postal` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`telephone` varchar(30) COLLATE utf8_bin DEFAULT NULL,
`tel_poste` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`actif` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Dumping data for table `fournisseurs`
--
INSERT INTO `fournisseurs` (`id_fournisseur`, `nom`, `succursale`, `nom_contact`, `role`, `adresse`, `ville`, `code_postal`, `telephone`, `tel_poste`, `actif`) VALUES
(2, 'Metro', 'Fournier', '', '', '850 Boulevard Thibeau', 'Trois-Rivières', 'G8T7A6', '8193763028', '', 1);
-- --------------------------------------------------------
--
-- Table structure for table `fraisgestion`
--
CREATE TABLE `fraisgestion` (
`id_frais` int(11) NOT NULL,
`frais` decimal(20,3) NOT NULL DEFAULT '0.000',
`type` varchar(15) COLLATE utf8_bin NOT NULL,
`actif` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Dumping data for table `fraisgestion`
--
INSERT INTO `fraisgestion` (`id_frais`, `frais`, `type`, `actif`) VALUES
(1, '1.000', 'pourcentage', 1),
(2, '0.000', 'fixe', 1);
--
-- Triggers `fraisgestion`
--
DELIMITER $$
CREATE TRIGGER `tbi_fraisgestion` BEFORE INSERT ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais, new.type, new.actif)
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `tbu_fraisgestion` BEFORE UPDATE ON `fraisgestion` FOR EACH ROW insert into historiquefraisgestion VALUES (new.id_frais, now(), new.frais, new.type, new.actif)
$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Table structure for table `historiquecommande`
--
CREATE TABLE `historiquecommande` (
`id_historique` int(11) NOT NULL,
`id_commande` int(11) DEFAULT NULL,
`id_compte` int(11) DEFAULT NULL,
`numero_commande` varchar(1024) COLLATE utf8_bin DEFAULT NULL,
`c_nom` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`c_prenom` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`c_courriel` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`date` datetime DEFAULT NULL,
`status` char(1) COLLATE utf8_bin DEFAULT NULL,
`prix_total` decimal(10,2) DEFAULT NULL,
`trace_paiement` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Triggers `historiquecommande`
--
DELIMITER $$
CREATE TRIGGER `tbd_historiquecommande` BEFORE DELETE ON `historiquecommande` FOR EACH ROW begin
delete from historiquecommandeproduit where historiquecommandeproduit.id_historique = old.id_historique;
end
$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Table structure for table `historiquecommandeproduit`
--
CREATE TABLE `historiquecommandeproduit` (
`id_historique` int(11) NOT NULL,
`id_produit` int(11) NOT NULL,
`p_nom` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`p_description` varchar(1024) COLLATE utf8_bin DEFAULT NULL,
`p_marque` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`p_commandemin` int(11) DEFAULT NULL,
`p_limiteachat` int(11) DEFAULT NULL,
`p_economie` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`p_unite` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`p_format` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`p_prix` decimal(20,2) NOT NULL,
`p_fraisfixe` decimal(20,2) NOT NULL,
`p_categorie` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`quantite` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `historiquefraisgestion`
--
CREATE TABLE `historiquefraisgestion` (
`id_frais` int(11) NOT NULL,
`date` datetime NOT NULL,
`frais` decimal(20,3) NOT NULL,
`type` varchar(15) COLLATE utf8_bin NOT NULL,
`actif` tinyint(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Dumping data for table `historiquefraisgestion`
--
INSERT INTO `historiquefraisgestion` (`id_frais`, `date`, `frais`, `type`, `actif`) VALUES
(1, '2018-12-06 20:13:47', '1.000', 'pourcentage', 1),
(2, '2018-12-06 20:13:53', '0.000', 'fixe', 1);
-- --------------------------------------------------------
--
-- Table structure for table `panier`
--
CREATE TABLE `panier` (
`id_compte` int(11) NOT NULL,
`id_produit` int(11) NOT NULL,
`quantite` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `password_resets`
--
CREATE TABLE `password_resets` (
`id_reset` int(11) NOT NULL,
`id_compte` int(11) DEFAULT NULL,
`selector` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`expires` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `produits`
--
CREATE TABLE `produits` (
`id_produit` int(11) NOT NULL,
`nom` varchar(255) COLLATE utf8_bin NOT NULL,
`description` varchar(1024) COLLATE utf8_bin DEFAULT NULL,
`marque` varchar(255) COLLATE utf8_bin NOT NULL,
`achat_minimum` int(10) NOT NULL,
`economie` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`image_produit` varchar(1024) COLLATE utf8_bin DEFAULT NULL,
`valeur_nutritive` varchar(1024) COLLATE utf8_bin DEFAULT NULL,
`format` int(11) NOT NULL,
`unite` varchar(15) COLLATE utf8_bin NOT NULL,
`limite_achat` int(11) DEFAULT NULL,
`categorie` int(11) NOT NULL,
`frais_fixe` decimal(20,2) NOT NULL DEFAULT '0.00',
`id_compte` int(11) DEFAULT NULL,
`status` char(1) COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Dumping data for table `produits`
--
INSERT INTO `produits` (`id_produit`, `nom`, `description`, `marque`, `achat_minimum`, `economie`, `image_produit`, `valeur_nutritive`, `format`, `unite`, `limite_achat`, `categorie`, `frais_fixe`, `id_compte`, `status`) VALUES
(6, 'Farine', 'Une bonne farine', 'Francine', 5, '', 'uploads_5bfd4b8be02ad7.90388594.jpg', NULL, 1, '1', 5, 3, '0.00', NULL, 'A'),
(7, 'Saucisse', 'Une bonne saucisse\'', 'La fernandière', 420, '', 'uploads_5bf716ec8045c1.37408180.jpg', NULL, 1, '1', 0, 2, '0.00', NULL, 'A'),
(8, 'Bleuet', 'De bons bleuets de la Gaspésie', 'Driscoll\'s', 36, 'Vous économisez 15% par rapport à IGA', 'uploads_5c09a6c0b41714.28565702.jpeg', 'uploads_5c09a6c0b44af7.43238973.png', 1, '1', 8, 1, '0.50', NULL, 'A');
--
-- Triggers `produits`
--
DELIMITER $$
CREATE TRIGGER `tau_produits` AFTER UPDATE ON `produits` FOR EACH ROW begin
if (new.limite_achat != 0) then
call updatelimiteproduit(new.id_produit, new.limite_achat);
end if;
end
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `tbd_produits` BEFORE DELETE ON `produits` FOR EACH ROW begin
delete from produitsfournisseurs where produitsfournisseurs.id_produit = old.id_produit;
end
$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Table structure for table `produitsfournisseurs`
--
CREATE TABLE `produitsfournisseurs` (
`id_produit` int(11) NOT NULL,
`id_fournisseur` int(11) NOT NULL,
`prix` decimal(10,2) NOT NULL,
`economie` decimal(4,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Dumping data for table `produitsfournisseurs`
--
INSERT INTO `produitsfournisseurs` (`id_produit`, `id_fournisseur`, `prix`, `economie`) VALUES
(6, 2, '12.00', NULL),
(7, 2, '10.00', NULL),
(8, 2, '8.00', NULL);
-- --------------------------------------------------------
--
-- Table structure for table `tracepaiements`
--
CREATE TABLE `tracepaiements` (
`id_paiement` int(11) NOT NULL,
`authorization` varchar(255) COLLATE utf8_bin NOT NULL,
`invoice` varchar(255) COLLATE utf8_bin NOT NULL,
`status` char(1) COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `access_token`
--
ALTER TABLE `access_token`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `categorie`
--
ALTER TABLE `categorie`
ADD PRIMARY KEY (`id_categorie`);
--
-- Indexes for table `commandes`
--
ALTER TABLE `commandes`
ADD PRIMARY KEY (`id_commande`,`id_compte`) USING BTREE,
ADD KEY `Commandes_fk0` (`id_compte`),
ADD KEY `Commandes_fk1` (`trace_paiement`),
ADD KEY `id_commande` (`id_commande`);
--
-- Indexes for table `commandesproduits`
--
ALTER TABLE `commandesproduits`
ADD PRIMARY KEY (`id_commande`,`id_produit`),
ADD KEY `CommandesProduits_fk1` (`id_produit`);
--
-- Indexes for table `commentaires`
--
ALTER TABLE `commentaires`
ADD PRIMARY KEY (`id_commentaire`,`id_compte`),
ADD KEY `Commentaires_fk0` (`id_compte`);
--
-- Indexes for table `comptes`
--
ALTER TABLE `comptes`
ADD PRIMARY KEY (`id_compte`),
ADD KEY `id_compte` (`id_compte`);
--
-- Indexes for table `configuration`
--
ALTER TABLE `configuration`
ADD PRIMARY KEY (`cle`);
--
-- Indexes for table `datescommandes`
--
ALTER TABLE `datescommandes`
ADD PRIMARY KEY (`id_periode`) USING BTREE;
--
-- Indexes for table `datespaiements`
--
ALTER TABLE `datespaiements`
ADD PRIMARY KEY (`date_debut`,`date_fin`);
--
-- Indexes for table `events`
--
ALTER TABLE `events`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `format`
--
ALTER TABLE `format`
ADD PRIMARY KEY (`id_format`),
ADD KEY `id_format` (`id_format`);
--
-- Indexes for table `fournisseurs`
--
ALTER TABLE `fournisseurs`
ADD PRIMARY KEY (`id_fournisseur`);
--
-- Indexes for table `fraisgestion`
--
ALTER TABLE `fraisgestion`
ADD PRIMARY KEY (`id_frais`);
--
-- Indexes for table `historiquecommande`
--
ALTER TABLE `historiquecommande`
ADD PRIMARY KEY (`id_historique`);
--
-- Indexes for table `historiquecommandeproduit`
--
ALTER TABLE `historiquecommandeproduit`
ADD PRIMARY KEY (`id_historique`,`id_produit`),
ADD KEY `historiquecommandeproduit_id_historique_index` (`id_historique`);
--
-- Indexes for table `historiquefraisgestion`
--
ALTER TABLE `historiquefraisgestion`
ADD PRIMARY KEY (`id_frais`,`date`);
--
-- Indexes for table `panier`
--
ALTER TABLE `panier`
ADD PRIMARY KEY (`id_compte`,`id_produit`) USING BTREE,
ADD KEY `Panier_fk0` (`id_produit`),
ADD KEY `id_compte` (`id_compte`);
--
-- Indexes for table `password_resets`
--
ALTER TABLE `password_resets`
ADD PRIMARY KEY (`id_reset`),
ADD KEY `comptes_fk0` (`id_compte`);
--
-- Indexes for table `produits`
--
ALTER TABLE `produits`
ADD PRIMARY KEY (`id_produit`),
ADD KEY `Produits_fk0` (`categorie`),
ADD KEY `Produits_fk1` (`id_compte`),
ADD KEY `format` (`format`);
--
-- Indexes for table `produitsfournisseurs`
--
ALTER TABLE `produitsfournisseurs`
ADD PRIMARY KEY (`id_produit`,`id_fournisseur`),
ADD KEY `ProduitsFournisseurs_fk1` (`id_fournisseur`);
--
-- Indexes for table `tracepaiements`
--
ALTER TABLE `tracepaiements`
ADD PRIMARY KEY (`id_paiement`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `access_token`
--
ALTER TABLE `access_token`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `categorie`
--
ALTER TABLE `categorie`
MODIFY `id_categorie` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `commandes`
--
ALTER TABLE `commandes`
MODIFY `id_commande` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
--
-- AUTO_INCREMENT for table `commentaires`
--
ALTER TABLE `commentaires`
MODIFY `id_commentaire` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `comptes`
--
ALTER TABLE `comptes`
MODIFY `id_compte` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;
--
-- AUTO_INCREMENT for table `events`
--
ALTER TABLE `events`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=20;
--
-- AUTO_INCREMENT for table `format`
--
ALTER TABLE `format`
MODIFY `id_format` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `fournisseurs`
--
ALTER TABLE `fournisseurs`
MODIFY `id_fournisseur` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `fraisgestion`
--
ALTER TABLE `fraisgestion`
MODIFY `id_frais` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `historiquecommande`
--
ALTER TABLE `historiquecommande`
MODIFY `id_historique` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
--
-- AUTO_INCREMENT for table `password_resets`
--
ALTER TABLE `password_resets`
MODIFY `id_reset` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
--
-- AUTO_INCREMENT for table `produits`
--
ALTER TABLE `produits`
MODIFY `id_produit` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `tracepaiements`
--
ALTER TABLE `tracepaiements`
MODIFY `id_paiement` int(11) NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `commandes`
--
ALTER TABLE `commandes`
ADD CONSTRAINT `Commandes_fk0` FOREIGN KEY (`id_compte`) REFERENCES `comptes` (`id_compte`),
ADD CONSTRAINT `Commandes_fk1` FOREIGN KEY (`trace_paiement`) REFERENCES `tracepaiements` (`id_paiement`);
--
-- Constraints for table `commandesproduits`
--
ALTER TABLE `commandesproduits`
ADD CONSTRAINT `CommandesProduits_fk0` FOREIGN KEY (`id_commande`) REFERENCES `commandes` (`id_commande`),
ADD CONSTRAINT `CommandesProduits_fk1` FOREIGN KEY (`id_produit`) REFERENCES `produits` (`id_produit`);
--
-- Constraints for table `commentaires`
--
ALTER TABLE `commentaires`
ADD CONSTRAINT `Commentaires_fk0` FOREIGN KEY (`id_compte`) REFERENCES `comptes` (`id_compte`);
--
-- Constraints for table `historiquecommandeproduit`
--
ALTER TABLE `historiquecommandeproduit`
ADD CONSTRAINT `histcomprod_fk0` FOREIGN KEY (`id_historique`) REFERENCES `historiquecommande` (`id_historique`);
--
-- Constraints for table `panier`
--
ALTER TABLE `panier`
ADD CONSTRAINT `panier_fk0` FOREIGN KEY (`id_compte`) REFERENCES `comptes` (`id_compte`),
ADD CONSTRAINT `panier_fk1` FOREIGN KEY (`id_produit`) REFERENCES `produits` (`id_produit`);
--
-- Constraints for table `password_resets`
--
ALTER TABLE `password_resets`
ADD CONSTRAINT `comptes_fk0` FOREIGN KEY (`id_compte`) REFERENCES `comptes` (`id_compte`);
--
-- Constraints for table `produits`
--
ALTER TABLE `produits`
ADD CONSTRAINT `Format_fk2` FOREIGN KEY (`format`) REFERENCES `format` (`id_format`),
ADD CONSTRAINT `Produits_fk0` FOREIGN KEY (`categorie`) REFERENCES `categorie` (`id_categorie`),
ADD CONSTRAINT `Produits_fk1` FOREIGN KEY (`id_compte`) REFERENCES `comptes` (`id_compte`);
--
-- Constraints for table `produitsfournisseurs`
--
ALTER TABLE `produitsfournisseurs`
ADD CONSTRAINT `ProduitsFournisseurs_fk0` FOREIGN KEY (`id_produit`) REFERENCES `produits` (`id_produit`),
ADD CONSTRAINT `ProduitsFournisseurs_fk1` FOREIGN KEY (`id_fournisseur`) REFERENCES `fournisseurs` (`id_fournisseur`);
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 */;