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
|
DROP TABLE incompatibilite ;
DROP TABLE allergie ;
DROP TABLE prescription ;
DROP TABLE patient ;
DROP TABLE medicament ;
DROP TABLE medecin ;
CREATE TABLE patient (
noPatient numeric(3),
nom varchar(10) NOT NULL
check(upper(nom) = nom),
prenom varchar(10) NOT NULL,
sexe char NOT NULL
check(sexe in ('M','F')),
age numeric(3) NOT NULL
check(age between 0 and 150),
CONSTRAINT patientPK PRIMARY KEY (noPatient)
);
CREATE TABLE medicament (
noMedicament numeric(3),
description varchar(10) NOT NULL,
noFabricant numeric(3) NOT NULL,
noMedicamentFabricant numeric(3) NOT NULL,
prix numeric(6,2) NOT NULL
check(prix >= 0),
CONSTRAINT medicamentPK PRIMARY KEY (noMedicament),
CONSTRAINT medicamentUKfm UNIQUE (noFabricant,noMedicamentFabricant)
);
CREATE TABLE medecin (
noMedecin numeric(3) NOT NULL,
nom varchar(10) NOT NULL,
prenom varchar(10) NOT NULL,
telephone numeric(10) NOT NULL,
CONSTRAINT medecinPK PRIMARY KEY (noMedecin)
);
CREATE TABLE prescription (
noMedicament numeric(3) NOT NULL,
noPatient numeric(3) NOT NULL,
dateDebutPrescrit char(10) NOT NULL,
dateFinPrescrit char(10) NOT NULL,
noMedecin numeric(3) NOT NULL,
CONSTRAINT prescriptionPK PRIMARY KEY (noMedicament,noPatient,dateDebutPrescrit),
CONSTRAINT presciptionFKm FOREIGN KEY (noMedicament) REFERENCES medicament,
CONSTRAINT presciptionFKp FOREIGN KEY (noPatient) REFERENCES patient,
CONSTRAINT prescriptionFKmed FOREIGN KEY (noMedecin) REFERENCES medecin
);
CREATE TABLE allergie (
noPatient numeric(3) NOT NULL,
noMedicament numeric(3) NOT NULL,
CONSTRAINT allergiePK PRIMARY KEY (noMedicament,noPatient),
CONSTRAINT allergieFKm FOREIGN KEY (noMedicament) REFERENCES medicament,
CONSTRAINT allergieFKp FOREIGN KEY (noPatient) REFERENCES patient
);
CREATE TABLE incompatibilite (
noMedicament1 numeric(3) NOT NULL,
noMedicament2 numeric(3) NOT NULL,
CONSTRAINT incompPK PRIMARY KEY (noMedicament1,noMedicament2),
CONSTRAINT incompFKm1 FOREIGN KEY (noMedicament1) REFERENCES medicament,
CONSTRAINT incompFKm2 FOREIGN KEY (noMedicament2) REFERENCES medicament
);
INSERT INTO patient (noPatient,nom,prenom,sexe,age)
VALUES (1,'P1','N1','M',31);
INSERT INTO patient (noPatient,nom,prenom,sexe,age)
VALUES (2,'P2','N2','F',19);
INSERT INTO patient (noPatient,nom,prenom,sexe,age)
VALUES (3,'PAT3','Nom3','M',20);
INSERT INTO patient (noPatient,nom,prenom,sexe,age)
VALUES (4,'PAT4','Nom4','F',30);
INSERT INTO patient (noPatient,nom,prenom,sexe,age)
VALUES (5,'P5','N5','F',31);
INSERT INTO medicament (noMedicament,description,noFabricant,noMedicamentFabricant,prix)
VALUES (1,'Medic 1',1,1,109.99);
INSERT INTO medicament (noMedicament,description,noFabricant,noMedicamentFabricant,prix)
VALUES (2,'Medic 2',2,1,210.25);
INSERT INTO medicament (noMedicament,description,noFabricant,noMedicamentFabricant,prix)
VALUES (3,'dnitro XyZ',10,10,109.99);
INSERT INTO medicament (noMedicament,description,noFabricant,noMedicamentFabricant,prix)
VALUES (4,'enItRo aBc',20,10,210.25);
INSERT INTO medecin (noMedecin,nom,prenom,telephone)
VALUES (1,'P1-med','N1-med',8198212096);
INSERT INTO medecin (noMedecin,nom,prenom,telephone)
VALUES (2,'P2-med','N2-med',8198211234);
INSERT INTO medecin (noMedecin,nom,prenom,telephone)
VALUES (3,'P3-med','N3-med',8198212096);
INSERT INTO medecin (noMedecin,nom,prenom,telephone)
VALUES (4,'P4-med','N4-med',8198211234);
INSERT INTO allergie (noPatient,noMedicament)
VALUES (1,2);
INSERT INTO allergie (noPatient,noMedicament)
VALUES (2,2);
INSERT INTO allergie (noPatient,noMedicament)
VALUES (4,3);
INSERT INTO allergie (noPatient,noMedicament)
VALUES (4,4);
INSERT INTO allergie (noPatient,noMedicament)
VALUES (5,2);
INSERT INTO incompatibilite (noMedicament1,noMedicament2)
VALUES (1,2);
INSERT INTO incompatibilite (noMedicament1,noMedicament2)
VALUES (3,4);
INSERT INTO prescription (noPatient,noMedicament,dateDebutPrescrit,dateFinPrescrit,nomedecin)
VALUES (1,1,'2001-01-24','2001-02-14',1);
INSERT INTO prescription (noPatient,noMedicament,dateDebutPrescrit,dateFinPrescrit,nomedecin)
VALUES (2,1,'2001-01-10','2001-01-14',2);
INSERT INTO prescription (noPatient,noMedicament,dateDebutPrescrit,dateFinPrescrit,nomedecin)
VALUES (3,3,'2001-01-24','2001-02-14',1);
INSERT INTO prescription (noPatient,noMedicament,dateDebutPrescrit,dateFinPrescrit,nomedecin)
VALUES (3,4,'2001-01-24','2001-01-14',2);
INSERT INTO prescription (noPatient,noMedicament,dateDebutPrescrit,dateFinPrescrit,nomedecin)
VALUES (1,2,'2000-02-24','2000-02-14',2);
INSERT INTO prescription (noPatient,noMedicament,dateDebutPrescrit,dateFinPrescrit,nomedecin)
VALUES (2,2,'2000-02-24','2000-02-14',2);
INSERT INTO prescription (noPatient,noMedicament,dateDebutPrescrit,dateFinPrescrit,nomedecin)
VALUES (3,1,'2000-01-10','2000-01-14',2);
INSERT INTO prescription (noPatient,noMedicament,dateDebutPrescrit,dateFinPrescrit,nomedecin)
VALUES (4,1,'2000-01-10','2000-01-14',2);
INSERT INTO prescription (noPatient,noMedicament,dateDebutPrescrit,dateFinPrescrit,nomedecin)
VALUES (5,1,'2000-01-10','2000-01-14',2);
INSERT INTO prescription (noPatient,noMedicament,dateDebutPrescrit,dateFinPrescrit,nomedecin)
VALUES (5,4,'2000-01-10','2000-01-14',2); |
Partager