1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
| --------------
SET AUTOCOMMIT = 0
--------------
--------------
START TRANSACTION
--------------
--------------
DROP DATABASE IF EXISTS `pharmacie`
--------------
--------------
CREATE DATABASE `pharmacie`
DEFAULT CHARACTER SET `utf8`
DEFAULT COLLATE `utf8_general_ci`
--------------
--------------
commit
--------------
--------------
DROP TABLE IF EXISTS `medecin`
--------------
--------------
CREATE TABLE `medecin`
( `medecin_id` BIGINT UNSIGNED NOT NULL PRIMARY KEY,
`nom` VARCHAR(255) NOT NULL,
`prenom` VARCHAR(255) NOT NULL,
`naissance` DATE NOT NULL,
`adresse` VARCHAR(255) NOT NULL,
`localite` VARCHAR(255) NOT NULL,
`code_postal` CHAR(005) NOT NULL
) ENGINE=InnoDB
DEFAULT CHARSET=`utf8` COLLATE=`utf8_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
commit
--------------
--------------
DROP TABLE IF EXISTS `client`
--------------
--------------
CREATE TABLE `client`
( `client_id` BIGINT UNSIGNED NOT NULL PRIMARY KEY,
`nom` VARCHAR(255) NOT NULL,
`prenom` VARCHAR(255) NOT NULL,
`naissance` DATE NOT NULL,
`adresse` VARCHAR(255) NOT NULL,
`localite` VARCHAR(255) NOT NULL,
`code_postal` CHAR(005) NOT NULL,
`commentaires` TEXT NOT NULL
) ENGINE=InnoDB
DEFAULT CHARSET=`utf8` COLLATE=`utf8_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
commit
--------------
--------------
DROP TABLE IF EXISTS `visite`
--------------
--------------
CREATE TABLE `visite`
( `visite_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`visite_date` DATE NOT NULL,
`medecin_id` BIGINT UNSIGNED NOT NULL,
`client_id` BIGINT UNSIGNED NOT NULL,
CONSTRAINT `FK_VISITE_MEDECIN` FOREIGN KEY (`medecin_id`) REFERENCES `medecin` (`medecin_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_VISITE_CLIENT` FOREIGN KEY (`client_id`) REFERENCES `client` (`client_id`) ON DELETE CASCADE ON UPDATE CASCADE,
UNIQUE INDEX `IDX_VISITE` (`visite_date`,`medecin_id`,`client_id`)
) ENGINE=InnoDB
DEFAULT CHARSET=`utf8` COLLATE=`utf8_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
commit
--------------
--------------
DROP TABLE IF EXISTS `medicament`
--------------
--------------
CREATE TABLE `medicament`
( `visite_id` BIGINT UNSIGNED NOT NULL,
`ligne` SMALLINT UNSIGNED NOT NULL,
`indication` TEXT NOT NULL,
`sous_prescription` BOOLEAN DEFAULT NULL,
`remboursement` BOOLEAN DEFAULT NULL,
CONSTRAINT `FK_MEDICAMENT_VISITE` FOREIGN KEY (`visite_id`) REFERENCES `visite` (`visite_id`) ON DELETE CASCADE ON UPDATE CASCADE,
primary key (`visite_id`,`ligne`)
) ENGINE=InnoDB
DEFAULT CHARSET=`utf8` COLLATE=`utf8_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
commit
--------------
--------------
DROP TABLE IF EXISTS `ordonnance`
--------------
--------------
CREATE TABLE `ordonnance`
( `visite_id` BIGINT UNSIGNED NOT NULL,
`ligne` SMALLINT UNSIGNED NOT NULL,
`indication` TEXT NOT NULL,
CONSTRAINT `FK_ORDONNANCE_VISITE` FOREIGN KEY (`visite_id`) REFERENCES `visite` (`visite_id`) ON DELETE CASCADE ON UPDATE CASCADE,
primary key (`visite_id`,`ligne`)
) ENGINE=InnoDB
DEFAULT CHARSET=`utf8` COLLATE=`utf8_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
COMMIT
--------------
--------------
SET AUTOCOMMIT = 1
--------------
Appuyez sur une touche pour continuer... |