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

462 lines
12 KiB
SQL

-- phpMyAdmin SQL Dump
-- version 4.6.5.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Nov 14, 2018 at 01:49 PM
-- Server version: 10.1.21-MariaDB
-- PHP Version: 7.1.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
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`
--
-- --------------------------------------------------------
--
-- 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 utf8mb4_unicode_ci NOT NULL,
`token` char(64) COLLATE utf8mb4_unicode_ci NOT NULL,
`expires` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `categorie`
--
CREATE TABLE `categorie` (
`id_categorie` int(11) NOT NULL,
`nom` varchar(255) CHARACTER SET latin1 NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `categorie`
--
INSERT INTO `categorie` (`id_categorie`, `nom`) VALUES
(1, 'Fruits et Légumes');
-- --------------------------------------------------------
--
-- Table structure for table `commandes`
--
CREATE TABLE `commandes` (
`id_commande` int(11) NOT NULL,
`id_compte` int(11) NOT NULL,
`date` datetime NOT NULL,
`status` char(1) CHARACTER SET latin1 NOT NULL,
`prix_total` decimal(5,3) NOT NULL,
`trace_paiement` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `commandesproduits`
--
CREATE TABLE `commandesproduits` (
`id_commande` int(11) NOT NULL,
`id_produit` int(11) NOT NULL,
`quantité` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- 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) CHARACTER SET latin1 NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `comptes`
--
CREATE TABLE `comptes` (
`id_compte` int(11) NOT NULL,
`courriel` varchar(255) CHARACTER SET latin1 NOT NULL,
`password` varchar(255) CHARACTER SET latin1 NOT NULL,
`nom` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`prenom` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`telephone` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`type` char(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'U'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `comptes`
--
INSERT INTO `comptes` (`id_compte`, `courriel`, `password`, `nom`, `prenom`, `telephone`, `type`) VALUES
(13, '[email protected]', '$2y$10$MScllzuG8gxIGoib2YlUBuoJnrq3.i6BFqNn0QTKGQHMyqCXhT43.', 'Robert', 'Anthony', '8199447206', 'A');
--
-- Triggers `comptes`
--
DELIMITER $$
CREATE TRIGGER `tai_comptes` AFTER INSERT ON `comptes` FOR EACH ROW insert into panier values(NEW.id_compte, null, null)
$$
DELIMITER ;
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) CHARACTER SET latin1 NOT NULL,
`valeur` varchar(4096) CHARACTER SET latin1 NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `datescommandes`
--
CREATE TABLE `datescommandes` (
`date_debut` datetime NOT NULL,
`date_fin` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `datespaiements`
--
CREATE TABLE `datespaiements` (
`date_debut` datetime NOT NULL,
`date_fin` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `format`
--
CREATE TABLE `format` (
`id_format` int(11) NOT NULL,
`nom` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `format`
--
INSERT INTO `format` (`id_format`, `nom`) VALUES
(1, 'kg');
-- --------------------------------------------------------
--
-- Table structure for table `fournisseurs`
--
CREATE TABLE `fournisseurs` (
`id_fournisseur` int(11) NOT NULL,
`nom` varchar(255) CHARACTER SET latin1 NOT NULL,
`adresse` varchar(1024) CHARACTER SET latin1 NOT NULL,
`telephone` varchar(30) CHARACTER SET latin1 NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `panier`
--
CREATE TABLE `panier` (
`id_compte` int(11) NOT NULL,
`id_produit` int(11) DEFAULT NULL,
`quantite` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `panier`
--
INSERT INTO `panier` (`id_compte`, `id_produit`, `quantite`) VALUES
(13, NULL, NULL);
-- --------------------------------------------------------
--
-- Table structure for table `produits`
--
CREATE TABLE `produits` (
`id_produit` int(11) NOT NULL,
`nom` varchar(255) CHARACTER SET latin1 NOT NULL,
`description` varchar(1024) CHARACTER SET latin1 NOT NULL,
`marque` varchar(255) CHARACTER SET latin1 NOT NULL,
`achat_minimum` int(10) NOT NULL,
`economie` decimal(4,2) DEFAULT NULL,
`image_produit` varchar(1024) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`valeur_nutritive` varchar(1024) CHARACTER SET latin1 DEFAULT NULL,
`format` int(11) NOT NULL,
`unite` varchar(15) CHARACTER SET latin1 NOT NULL,
`limite_achat` int(11) DEFAULT NULL,
`categorie` int(11) NOT NULL,
`id_compte` int(11) DEFAULT NULL,
`status` char(1) CHARACTER SET latin1 NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `produitsfournisseurs`
--
CREATE TABLE `produitsfournisseurs` (
`id_produit` int(11) NOT NULL,
`id_fournisseur` int(11) NOT NULL,
`prix` decimal(5,3) NOT NULL,
`economie` decimal(4,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `tracepaiements`
--
CREATE TABLE `tracepaiements` (
`id_paiement` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- 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`),
ADD KEY `Commandes_fk0` (`id_compte`),
ADD KEY `Commandes_fk1` (`trace_paiement`);
--
-- 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 (`date_debut`,`date_fin`);
--
-- Indexes for table `datespaiements`
--
ALTER TABLE `datespaiements`
ADD PRIMARY KEY (`date_debut`,`date_fin`);
--
-- 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 `panier`
--
ALTER TABLE `panier`
ADD PRIMARY KEY (`id_compte`) USING BTREE,
ADD KEY `Panier_fk0` (`id_produit`);
--
-- 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=2;
--
-- AUTO_INCREMENT for table `commandes`
--
ALTER TABLE `commandes`
MODIFY `id_commande` int(11) NOT NULL AUTO_INCREMENT;
--
-- 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=14;
--
-- 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 for table `produits`
--
ALTER TABLE `produits`
MODIFY `id_produit` int(11) NOT NULL AUTO_INCREMENT;
--
-- 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 `panier`
--
ALTER TABLE `panier`
ADD CONSTRAINT `Panier_fk0` FOREIGN KEY (`id_produit`) REFERENCES `produits` (`id_produit`),
ADD CONSTRAINT `panier_ibfk_1` 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`);
/*!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 */;