Commit 06059fcb authored by Nu Huyen Trang Pham's avatar Nu Huyen Trang Pham
Browse files

Update create_table.sql

parent c103b8f9
......@@ -10,8 +10,7 @@ Create table Client (
);
Create table Classe_animal (
ID_classes INT UNIQUE NOT NULL PRIMARY KEY,
Nom varchar(30) NOT NULL
Nom varchar(30) NOT NULL PRIMARY Key
);
Create table Veterinaire (
......@@ -21,8 +20,8 @@ Create table Veterinaire (
Date_de_naissance date NOT NULL,
Addresse varchar(100) NOT NULL,
Numero_de_telephone varchar(30) NOT NULL,
Specialite INT,
foreign key (Specialite) references Classe_animal(ID_classes)
Specialite varchar(30),
foreign key (Specialite) references Classe_animal(Nom)
);
Create table Assistant (
......@@ -32,29 +31,28 @@ Create table Assistant (
Date_de_naissance date NOT NULL,
Addresse varchar(100) NOT NULL,
Numero_de_telephone varchar(30) NOT NULL,
Specialite INT,
foreign key (Specialite) references Classe_animal(ID_classes)
Specialite varchar(30),
foreign key (Specialite) references Classe_animal(Nom)
);
Create table Espece (
ID_espece INT UNIQUE NOT NULL PRIMARY KEY,
Nom varchar(30) NOT NULL,
Classe INT,
foreign key(Classe) references Classe_animal(ID_classes)
Nom varchar(30) NOT NULL PRIMARY KEY,
Classe varchar(30),
foreign key(Classe) references Classe_animal(Nom)
);
/*Ici on suppose que il reste des animaux qui ont même nom*/
Create table Animal (
ID_Animal INT UNIQUE NOT NULL PRIMARY KEY,
Nom varchar(30) NOT NULL,
Poids FLOAT NOT NULL,
Taille FLOAT NOT NULL,
Date_de_naissance date,
ID_Espece INT,
foreign key(ID_Espece) references Espece(ID_espece),
Espece varchar(30),
foreign key(Espece) references Espece(Nom),
ID_Client INT,
foreign key(ID_Client) references Client(ID_Client),
CHECK (Poids > 0),
CHECK (Taille > 0)
CHECK ((Poids > 0) AND (Taille > 0))
);
Create table Effets_secondaires (
......@@ -63,25 +61,26 @@ Create table Effets_secondaires (
);
Create table Medicament (
ID_Medicament INT UNIQUE NOT NULL PRIMARY KEY,
Nom_de_molecule varchar(30) NOT NULL,
Nom_de_molecule varchar(30) NOT NULL PRIMARY KEY,
Description varchar(100) NOT NULL
);
/*C'est une classe d'association*/
Create table Medicament_Effet (
Medicament INT,
foreign key(Medicament) references Medicament(ID_Medicament),
Medicament varchar(30),
foreign key(Medicament) references Medicament(Nom_de_molecule),
Effets_secondaires INT,
foreign key(Effets_secondaires) references Effets_secondaires(ID_effet_secondaire)
foreign key(Effets_secondaires) references Effets_secondaires(ID_effet_secondaire),
PRIMARY KEY(Medicament,Effets_secondaires)
);
/*C'est une classe d'association*/
Create table Med_correspond_Ani (
ID_Medicament INT,
foreign key(ID_Medicament) references Medicament(ID_Medicament),
ID_espece INT,
foreign key(ID_Espece) references Espece(ID_espece)
Medicament varchar(30),
foreign key(Medicament) references Medicament(Nom_de_molecule),
Espece varchar(30),
foreign key(Espece) references Espece(Nom),
PRIMARY KEY(Medicament,Espece)
);
Create table Traitement (
......@@ -100,8 +99,9 @@ Create table Traitement (
Create table Traitement_Medicament (
Traitement INT,
foreign key(Traitement) references Traitement(ID_Traitement),
ID_Medicament INT,
foreign key(ID_Medicament) references Medicament(ID_Medicament),
Medicament VARCHAR(30),
foreign key(Medicament) references Medicament(Nom_de_molecule),
Quantite_medicaments_pj INT NOT NULL,
CHECK (Quantite_medicaments_pj > 0)
CHECK (Quantite_medicaments_pj > 0),
PRIMARY KEY(Traitement,Medicament)
);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment