SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';

DROP SCHEMA IF EXISTS `demo1db` ;
CREATE SCHEMA IF NOT EXISTS `demo1db` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `demo1db` ;

-- -----------------------------------------------------
-- Table `demo1db`.`personne`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `demo1db`.`personne` ;

CREATE  TABLE IF NOT EXISTS `demo1db`.`personne` (
  `idpersonne` INT NOT NULL AUTO_INCREMENT ,
  `nom` VARCHAR(45) NOT NULL ,
  `prenom` VARCHAR(45) NOT NULL ,
  PRIMARY KEY (`idpersonne`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `demo1db`.`numero_telephone`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `demo1db`.`numero_telephone` ;

CREATE  TABLE IF NOT EXISTS `demo1db`.`numero_telephone` (
  `numero_telephone` VARCHAR(45) NOT NULL ,
  `personne_idpersonne` INT NOT NULL ,
  PRIMARY KEY (`numero_telephone`) ,
  INDEX `fk_numero_telephone_personne` (`personne_idpersonne` ASC) ,
  CONSTRAINT `fk_numero_telephone_personne`
    FOREIGN KEY (`personne_idpersonne` )
    REFERENCES `demo1db`.`personne` (`idpersonne` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB;



SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

-- -----------------------------------------------------
-- Data for table `demo1db`.`personne`
-- -----------------------------------------------------
START TRANSACTION;
USE `demo1db`;
INSERT INTO `demo1db`.`personne` (`idpersonne`, `nom`, `prenom`) VALUES (1, 'Durand', 'Jean');
INSERT INTO `demo1db`.`personne` (`idpersonne`, `nom`, `prenom`) VALUES (2, 'Dupond', 'Paul');

COMMIT;

-- -----------------------------------------------------
-- Data for table `demo1db`.`numero_telephone`
-- -----------------------------------------------------
START TRANSACTION;
USE `demo1db`;
INSERT INTO `demo1db`.`numero_telephone` (`numero_telephone`, `personne_idpersonne`) VALUES ('400000000', 1);
INSERT INTO `demo1db`.`numero_telephone` (`numero_telephone`, `personne_idpersonne`) VALUES ('600000000', 1);
INSERT INTO `demo1db`.`numero_telephone` (`numero_telephone`, `personne_idpersonne`) VALUES ('100000000', 2);

COMMIT;
