Skip to content

Instantly share code, notes, and snippets.

@vykio
Last active January 14, 2022 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vykio/b3427b5a0eb61d8067103671412584c7 to your computer and use it in GitHub Desktop.
Save vykio/b3427b5a0eb61d8067103671412584c7 to your computer and use it in GitHub Desktop.
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 : `MaBootique`
--
-- --------------------------------------------------------
--
-- Structure de la table `Categorie`
--
CREATE TABLE `categorie` (
`id` int(11) NOT NULL,
`nom` varchar(45) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Déchargement des données de la table `Categorie`
--
INSERT INTO `categorie` (`id`, `nom`) VALUES
(1, 'Test');
-- --------------------------------------------------------
--
-- Structure de la table `client`
--
CREATE TABLE `client` (
`id` int(11) NOT NULL,
`nom` varchar(45) NOT NULL,
`email` varchar(45) NOT NULL,
`telephone` varchar(10) NOT NULL,
`adresse` varchar(250) NOT NULL,
`password` varchar(25) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Déchargement des données de la table `client`
--
INSERT INTO `client` (`id`, `nom`, `email`, `telephone`, `adresse`, `password`) VALUES
(1, 'vykio', 'alexandre@ok.fr', '3630', '1 Rue de l\'avenue', '123456');
INSERT INTO `client` (`id`, `nom`, `email`, `telephone`, `adresse`, `password`) VALUES
(1, 'legault', 'leurette.gauthier@gmail.com', '3630', '2 Rue de l\'avenue', '123456');
-- --------------------------------------------------------
--
-- Structure de la table `Commande_client`
--
CREATE TABLE `commande_client` (
`id` int(11) NOT NULL,
`montant` decimal(6,2) NOT NULL,
`date_creation` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`no_confirmation` int(11) NOT NULL,
`client_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Structure de la table `Produit`
--
CREATE TABLE `produit` (
`id` int(11) NOT NULL,
`nom` varchar(45) NOT NULL,
`prix` decimal(5,2) NOT NULL,
`description` varchar(250) NOT NULL,
`dernier_maj` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`categorie_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Déchargement des données de la table `Produit`
--
INSERT INTO `produit` (`id`, `nom`, `prix`, `description`, `dernier_maj`, `categorie_id`) VALUES
(1, 'Ordinateur', '50.00', 'Ordinateur de fou', '2021-12-24 16:18:47', 1);
-- --------------------------------------------------------
--
-- Structure de la table `Produit_commande`
--
CREATE TABLE `produit_commande` (
`commande_client_id` int(11) NOT NULL,
`produit_id` int(11) NOT NULL,
`quantite` int(2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Index pour les tables déchargées
--
--
-- Index pour la table `Categorie`
--
ALTER TABLE `categorie`
ADD PRIMARY KEY (`id`);
--
-- Index pour la table `client`
--
ALTER TABLE `client`
ADD PRIMARY KEY (`id`);
--
-- Index pour la table `Commande_client`
--
ALTER TABLE `commande_client`
ADD PRIMARY KEY (`id`),
ADD KEY `fk_commande_client` (`client_id`);
--
-- Index pour la table `Produit`
--
ALTER TABLE `produit`
ADD PRIMARY KEY (`id`),
ADD KEY `fk_produit_categorie` (`categorie_id`);
--
-- Index pour la table `Produit_commande`
--
ALTER TABLE `produit_commande`
ADD KEY `fk_produit_commande` (`produit_id`);
--
-- AUTO_INCREMENT pour les tables déchargées
--
--
-- AUTO_INCREMENT
--
ALTER TABLE `client` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `categorie` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `commande_client` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `produit` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- Contraintes pour les tables déchargées
--
--
-- Contraintes pour la table `Commande_client`
--
ALTER TABLE `commande_client`
ADD CONSTRAINT `fk_commande_client` FOREIGN KEY (`client_id`) REFERENCES `client` (`id`);
--
-- Contraintes pour la table `Produit`
--
ALTER TABLE `produit`
ADD CONSTRAINT `fk_produit_categorie` FOREIGN KEY (`categorie_id`) REFERENCES `categorie` (`id`) ON DELETE CASCADE;
--
-- Contraintes pour la table `Produit_commande`
--
ALTER TABLE 'produit_commande'
ADD CONSTRAINT 'Fk_commande' FOREIGN KEY ('commande_client_id') REFERENCES 'commande_client' ('id'),
ADD CONSTRAINT `fk_produit_commande` FOREIGN KEY (`produit_id`) REFERENCES `produit` (`id`);
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 */;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment