Corresction de la BDD

This commit is contained in:
SeekDaSky 2015-12-03 09:54:20 +01:00
parent b3d87e4664
commit 801b795419
1 changed files with 133 additions and 77 deletions

View File

@ -1,84 +1,140 @@
-- MySQL Workbench Forward Engineering
-- phpMyAdmin SQL Dump
-- version 4.2.12deb2+deb8u1
-- http://www.phpmyadmin.net
--
-- Client : localhost
-- Généré le : Jeu 03 Décembre 2015 à 09:52
-- Version du serveur : 5.5.46-0+deb8u1
-- Version de PHP : 5.6.14-0+deb8u1
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;
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
-- -----------------------------------------------------
-- 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;
/*!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 : `msl1911a`
--
-- -----------------------------------------------------
-- 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;
-- --------------------------------------------------------
--
-- Structure de la table `Medecin`
--
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
CREATE TABLE IF NOT EXISTS `Medecin` (
`Id` int(11) NOT NULL,
`Civilite` char(1) NOT NULL,
`Prenom` varchar(45) NOT NULL,
`Nom` varchar(45) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Structure de la table `Patient`
--
CREATE TABLE IF NOT EXISTS `Patient` (
`Civilite` char(1) NOT NULL,
`Nom` varchar(45) CHARACTER SET big5 NOT NULL,
`Prenom` varchar(45) NOT NULL,
`Adresse` varchar(255) NOT NULL,
`Adresse 2` varchar(255) DEFAULT NULL,
`Ville` varchar(50) NOT NULL,
`CodePostal` varchar(4) NOT NULL,
`DateNaissance` date NOT NULL,
`LieuNaissance` varchar(50) NOT NULL,
`NumSecuriteSociale` varchar(15) NOT NULL,
`Id` int(11) NOT NULL,
`MedecinTraitant` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- RELATIONS POUR LA TABLE `Patient`:
-- `MedecinTraitant`
-- `Medecin` -> `id`
--
-- --------------------------------------------------------
--
-- Structure de la table `RDV`
--
CREATE TABLE IF NOT EXISTS `RDV` (
`Id` int(11) NOT NULL,
`DateRDV` timestamp NULL DEFAULT NULL,
`Duree` time DEFAULT NULL,
`Patient_Id` int(11) NOT NULL,
`Medecin_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- RELATIONS POUR LA TABLE `RDV`:
-- `Patient_Id`
-- `Patient` -> `Id`
-- `Medecin_id`
-- `Medecin` -> `id`
--
--
-- Index pour les tables exportées
--
--
-- Index pour la table `Medecin`
--
ALTER TABLE `Medecin`
ADD PRIMARY KEY (`Id`), ADD UNIQUE KEY `id_UNIQUE` (`Id`);
--
-- Index pour la table `Patient`
--
ALTER TABLE `Patient`
ADD PRIMARY KEY (`Id`), ADD UNIQUE KEY `NumSecuriteSociale_UNIQUE` (`NumSecuriteSociale`), ADD UNIQUE KEY `Id_UNIQUE` (`Id`), ADD KEY `fk_Patient_Medecin_idx` (`MedecinTraitant`);
--
-- Index pour la table `RDV`
--
ALTER TABLE `RDV`
ADD PRIMARY KEY (`Id`), ADD KEY `fk_RDV_Patient1_idx` (`Patient_Id`), ADD KEY `fk_RDV_Medecin1_idx` (`Medecin_id`);
--
-- AUTO_INCREMENT pour les tables exportées
--
--
-- AUTO_INCREMENT pour la table `Medecin`
--
ALTER TABLE `Medecin`
MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT pour la table `Patient`
--
ALTER TABLE `Patient`
MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;
--
-- Contraintes pour les tables exportées
--
--
-- Contraintes pour la table `Patient`
--
ALTER TABLE `Patient`
ADD CONSTRAINT `fk_Patient_Medecin` FOREIGN KEY (`MedecinTraitant`) REFERENCES `Medecin` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
--
-- Contraintes pour la table `RDV`
--
ALTER TABLE `RDV`
ADD CONSTRAINT `fk_RDV_Patient1` FOREIGN KEY (`Patient_Id`) REFERENCES `Patient` (`Id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_RDV_Medecin1` FOREIGN KEY (`Medecin_id`) REFERENCES `Medecin` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
/*!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 */;