Commit 9ba147f3 authored by Gaetan Carabetta's avatar Gaetan Carabetta

Update Table

parent 022bc513
DROP TABLE IF EXISTS Client;
CREATE TABLE Client (
idClient int NOT NULL,
nom varchar (20) NOT NULL,
prenom varchar (20) NOT NULL,
ddn date NOT NULL,
adresse varchar (100),
numero integer,
PRIMARY KEY (idClient)
CREATE TABLE Client(
idClient INT,
nom VARCHAR(30) NOT NULL,
prenon VARCHAR(30) NOT NULL,
ddn DATE NOT NULL,
adresse VARCHAR(100) NOT NULL,
numero NUMERIC(10) NOT NULL,
PRIMARY KEY(idClient)
);
DROP TABLE IF EXISTS Assistant;
CREATE TABLE Assistant(
idAssistant int NOT NULL,
nom varchar (20) NOT NULL,
prenom varchar (20) NOT NULL,
ddn date NOT NULL,
adresse varchar (100),
numero integer,
specialite varchar (50),
PRIMARY KEY (idAssistant)
);
idAssistant INT,
nom VARCHAR(30) NOT NULL,
prenon VARCHAR(30) NOT NULL,
ddn DATE NOT NULL,
adresse VARCHAR(100) NOT NULL,
numero NUMERIC(10) NOT NULL,
PRIMARY KEY(idAssistant)
);
DROP TABLE IF EXISTS Veterinaire;
CREATE TABLE Veterinaire(
idVet int NOT NULL,
nom varchar (20) NOT NULL,
prenom varchar (20) NOT NULL,
ddn date NOT NULL,
adresse varchar (100),
numero integer,
specialite varchar (50),
PRIMARY KEY (idVet)
);
idVeterinaire INT,
nom VARCHAR(30) NOT NULL,
prenon VARCHAR(30) NOT NULL,
ddn DATE NOT NULL,
adresse VARCHAR(100) NOT NULL,
numero NUMERIC(10) NOT NULL,
PRIMARY KEY(idVeterinaire)
);
DROP TABLE IF EXISTS ClasseEspece;
CREATE TABLE ClasseEspece (
nomClasse varchar (20) NOT NULL,
PRIMARY KEY (nomClasse)
);
CREATE TABLE Classe_espece(
nomClasse VARCHAR(30),
PRIMARY KEY(nomClasse)
);
DROP TABLE IF EXISTS Espece;
CREATE TABLE Espece (
nomEspece varchar (30) NOT NULL,
nomClasse varchar (20) NOT NULL,
PRIMARY KEY (nomEspece),
FOREIGN KEY (nomClasse) REFERENCES ClasseEspece (nomClasse)
);
CREATE TABLE Espece(
nomEspece VARCHAR(30),
nomClasse VARCHAR(30),
PRIMARY KEY(nomEspece),
FOREIGN KEY(nomClasse) REFERENCES Classe_espece(nomClasse)
);
DROP TABLE IF EXISTS Animal;
CREATE TABLE Animal(
idAnimal int NOT NULL,
nom varchar (20) NOT NULL,
poids float NOT NULL,
taille float NOT NULL,
ddn date,
PRIMARY KEY (idAnimal)
);
idAnimal INT,
nom VARCHAR(30) NOT NULL,
poids REAL NOT NULL,
taille REAL NOT NULL,
naissance DATE,
idClient INT,
especeNom VARCHAR(30),
PRIMARY KEY(idAnimal),
FOREIGN KEY (idClient) REFERENCES Client(idClient),
FOREIGN KEY (especeNom) REFERENCES Espece(nomEspece)
);
DROP TABLE IF EXISTS Medicament;
CREATE TABLE Medicament(
nomMolec varchar (30) NOT NULL,
description varchar (100) NOT NULL,
PRIMARY KEY (nomMolec)
);
nomMolec VARCHAR(30),
description VARCHAR(200) NOT NULL,
PRIMARY KEY(nomMolec)
);
DROP TABLE IF EXISTS Espece_Med;
CREATE TABLE Espece_Med(
nomEspece varchar (30) NOT NULL,
nomMolec varchar (30) NOT NULL,
PRIMARY KEY (nomEspece,nomMolec),
FOREIGN KEY (nomEspece) REFERENCES Espece (nomEspece),
FOREIGN KEY (nomMolec) REFERENCES Medicament (nomMolec)
);
DROP TABLE IF EXISTS Traitement;
CREATE TABLE Traitement(
idTraitement int NOT NULL,
idAnimal int NOT NULL,
idVet int NOT NULL,
PRIMARY KEY (idTraitement),
FOREIGN KEY (idAnimal) REFERENCES Animal (idAnimal),
FOREIGN KEY (idVet) REFERENCES Veterinaire (idVet)
);
idTraitement INT,
idAnimal INT,
idVeterinaire INT,
PRIMARY KEY(idTraitement),
FOREIGN KEY(idVeterinaire) REFERENCES Veterinaire(idVeterinaire),
FOREIGN KEY(idAnimal) REFERENCES Animal(idAnimal)
);
CREATE TABLE Espece_medicament(
nomEspece VARCHAR(30),
nomMolec VARCHAR(30),
FOREIGN KEY(nomEspece) REFERENCES Espece(nomEspece),
FOREIGN KEY(nomMolec) REFERENCES Medicament(nomMolec)
);
DROP TABLE IF EXISTS Posologie;
CREATE TABLE Posologie(
idTraitement int NOT NULL,
nomMolec varchar (30) NOT NULL,
PRIMARY KEY (idTraitement,nomMolec),
FOREIGN KEY (idTraitement) REFERENCES Traitement (idTraitement),
FOREIGN KEY (nomMolec) REFERENCES Medicament (nomMolec)
);
idAnimal INT REFERENCES Animal(idAnimal),
nomMolec VARCHAR(30) REFERENCES Medicament(nomMolec),
debut DATE,
duree INT NOT NULL,
nbJourna INT NOT NULL,
PRIMARY KEY(idAnimal, nomMolec, debut)
);
/*Methodes*/
/*à tester*/
......
Markdown is supported
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