projet-php/Docs/BDD.sql

85 lines
2.8 KiB
MySQL
Raw Normal View History

2015-12-02 10:58:45 +00:00
-- MySQL Workbench Forward Engineering
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,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema projetphp
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema projetphp
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `projetphp` DEFAULT CHARACTER SET utf8 ;
USE `projetphp` ;
-- -----------------------------------------------------
-- Table `projetphp`.`Medecin`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `projetphp`.`Medecin` (
`id` INT NOT NULL AUTO_INCREMENT,
`Civilite` CHAR(1) NOT NULL,
`Prenom` VARCHAR(45) NOT NULL,
`Nom` VARCHAR(45) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `id_UNIQUE` (`id` ASC))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `projetphp`.`Patient`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `projetphp`.`Patient` (
`Civilite` CHAR(1) NOT NULL,
`Nom` VARCHAR(45) CHARACTER SET 'big5' NOT NULL,
`Prenom` VARCHAR(45) NOT NULL,
`Adresse` VARCHAR(100) NOT NULL,
`Ville` VARCHAR(50) NOT NULL,
`CodePostal` SMALLINT(4) NOT NULL,
`DateNaissance` DATE NOT NULL,
`LieuNaissance` VARCHAR(50) NOT NULL,
`NumSecuriteSociale` INT(15) NOT NULL,
`Id` INT NOT NULL AUTO_INCREMENT,
`MedecinTraitant` INT NULL,
UNIQUE INDEX `NumSecuriteSociale_UNIQUE` (`NumSecuriteSociale` ASC),
PRIMARY KEY (`Id`),
UNIQUE INDEX `Id_UNIQUE` (`Id` ASC),
INDEX `fk_Patient_Medecin_idx` (`MedecinTraitant` ASC),
CONSTRAINT `fk_Patient_Medecin`
FOREIGN KEY (`MedecinTraitant`)
REFERENCES `projetphp`.`Medecin` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `projetphp`.`RDV`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `projetphp`.`RDV` (
`id` INT NOT NULL,
`DateRDV` TIMESTAMP NULL,
`Duree` TIME NULL,
`Patient_Id` INT NOT NULL,
`Medecin_id` INT NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_RDV_Patient1_idx` (`Patient_Id` ASC),
INDEX `fk_RDV_Medecin1_idx` (`Medecin_id` ASC),
CONSTRAINT `fk_RDV_Patient1`
FOREIGN KEY (`Patient_Id`)
REFERENCES `projetphp`.`Patient` (`Id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_RDV_Medecin1`
FOREIGN KEY (`Medecin_id`)
REFERENCES `projetphp`.`Medecin` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;