-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Client :  127.0.0.1
-- Généré le :  Jeu 21 Décembre 2017 à 21:12
-- Version du serveur :  5.6.17
-- Version de PHP :  5.5.12

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 utf8 */;

--
-- Base de données :  `m2i`
--

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

--
-- Structure de la table `article`
--

CREATE TABLE IF NOT EXISTS `article` (
  `codeA` int(5) NOT NULL AUTO_INCREMENT,
  `designation` varchar(20) NOT NULL,
  `prixU` int(6) DEFAULT NULL,
  `stock` int(4) DEFAULT '0',
  PRIMARY KEY (`codeA`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;

--
-- Contenu de la table `article`
--

INSERT INTO `article` (`codeA`, `designation`, `prixU`, `stock`) VALUES
(1, 'Ecran', 300, 3),
(2, 'Souris', 20, 4),
(3, 'Clavier', 50, 1),
(5, 'RJ45', 5, 3),
(6, 'telephone fixe', 25, 4),
(7, 'telephone portable', 250, 5);

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

--
-- Structure de la table `client`
--

CREATE TABLE IF NOT EXISTS `client` (
  `id` int(3) NOT NULL AUTO_INCREMENT,
  `nom` varchar(20) NOT NULL,
  `prenom` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

--
-- Contenu de la table `client`
--

INSERT INTO `client` (`id`, `nom`, `prenom`) VALUES
(1, 'john', 'wick'),
(2, 'Dupont', 'Marcel'),
(3, 'Angel', 'Maria'),
(4, 'Jordan', 'Sami'),
(5, 'Cooper', 'Alice');

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

--
-- Structure de la table `commande`
--

CREATE TABLE IF NOT EXISTS `commande` (
  `numeroC` int(8) NOT NULL AUTO_INCREMENT,
  `date` varchar(10) DEFAULT NULL,
  `id` int(3) DEFAULT NULL,
  PRIMARY KEY (`numeroC`),
  KEY `fk_commande` (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;

--
-- Contenu de la table `commande`
--

INSERT INTO `commande` (`numeroC`, `date`, `id`) VALUES
(1, '30/07/2017', 2),
(2, '25/10/2017', 1),
(3, '22/12/2017', 3),
(4, '27/09/2017', 1),
(5, '14/09/2017', 5),
(6, '24/08/2017', 4),
(7, '31/08/2017', 4),
(8, '01/09/2017', 4);

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

--
-- Structure de la table `lignecommande`
--

CREATE TABLE IF NOT EXISTS `lignecommande` (
  `codeA` int(5) NOT NULL DEFAULT '0',
  `numeroC` int(8) NOT NULL DEFAULT '0',
  `quantite` int(2) DEFAULT NULL,
  PRIMARY KEY (`codeA`,`numeroC`),
  KEY `numeroC` (`numeroC`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Contenu de la table `lignecommande`
--

INSERT INTO `lignecommande` (`codeA`, `numeroC`, `quantite`) VALUES
(1, 1, 2),
(1, 2, 1),
(2, 2, 2),
(2, 6, 2),
(5, 1, 1),
(5, 3, 8),
(5, 4, 3),
(5, 6, 2);

--
-- Contraintes pour les tables exportées
--

--
-- Contraintes pour la table `commande`
--
ALTER TABLE `commande`
  ADD CONSTRAINT `fk_commande` FOREIGN KEY (`id`) REFERENCES `client` (`id`);

--
-- Contraintes pour la table `lignecommande`
--
ALTER TABLE `lignecommande`
  ADD CONSTRAINT `lignecommande_ibfk_1` FOREIGN KEY (`codeA`) REFERENCES `article` (`codeA`),
  ADD CONSTRAINT `lignecommande_ibfk_2` FOREIGN KEY (`numeroC`) REFERENCES `commande` (`numeroC`);

/*!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 */;
