Commit bac92576 authored by Gaetan Carabetta's avatar Gaetan Carabetta

Update SQL_OO.sql

parent 2e010c08
DROP TABLE Client;
DROP TYPE ListeRefAnimal;
DROP TYPE RefAnimal;
DROP TABLE tAnimal;
DROP TYPE Animal;
DROP TYPE ListeRefTraitement;
DROP TYPE RefTraitement;
DROP TABLE tTraitement;
DROP TYPE Traitement FORCE;
DROP TYPE listePosologies;
DROP TYPE Posologie;
DROP TABLE tMedicament;
DROP TYPE Medicament;
DROP TYPE ListeRefEspece;
DROP TYPE RefEspece;
DROP TABLE tEspece;
DROP TYPE Espece;
DROP TABLE Veterinaire;
DROP TABLE Assistant;
DROP TABLE tClasseEspece;
DROP TYPE ClasseEspece;
CREATE OR REPLACE TYPE ClasseEspece AS OBJECT (
nomClasse VARCHAR(20)
);
......@@ -9,24 +31,26 @@ CREATE TABLE tClasseEspece OF ClasseEspece (
/
CREATE TABLE Assistant (
idAssistant INTEGER NOT NULL PRIMARY KEY,
idAssistant INTEGER PRIMARY KEY,
nom VARCHAR (20) NOT NULL,
prenom VARCHAR(20) NOT NULL,
ddn DATE NOT NULL,
numero VARCHAR (10) NOT NULL,
specialite REF ClasseEspece,
CHECK (numero BETWEEN 0000000000 AND 0799999999)
SCOPE FOR (specialite) IS tClasseEspece,
CHECK (numero BETWEEN 0100000000 AND 0799999999)
);
/
CREATE TABLE Veterinaire (
idVeterinaire INTEGER NOT NULL PRIMARY KEY,
idVeterinaire INTEGER PRIMARY KEY,
nom VARCHAR (20) NOT NULL,
prenom VARCHAR(20) NOT NULL,
ddn DATE NOT NULL,
numero VARCHAR (10) NOT NULL,
specialite REF ClasseEspece, --Je sais pas comment faire ça, on l'a fait dans le test mais j'ai pas la correction
specialite REF ClasseEspece,
SCOPE FOR (specialite) IS tClasseEspece,
CHECK (numero BETWEEN 0000000000 AND 0799999999)
);
/
......@@ -55,8 +79,8 @@ CREATE OR REPLACE TYPE ListeRefEspece AS TABLE OF RefEspece;
CREATE OR REPLACE TYPE Medicament AS OBJECT(
nomMolec VARCHAR(20),
description VARCHAR(100),
especes ListeRefEspece,
descriptions VARCHAR(100),
especes ListeRefEspece
--MEMBER FUNCTION espece_autoriser(espece IN|OUT VARCHAR(20)) RETURN BOOLEAN
);
/
......@@ -78,7 +102,7 @@ END;
CREATE TABLE tMedicament OF Medicament(
PRIMARY KEY (nomMolec),
description NOT NULL,
descriptions NOT NULL
) NESTED TABLE especes STORE AS ntRefEspeces;
/
......@@ -95,10 +119,6 @@ CREATE OR REPLACE TYPE Posologie AS OBJECT(
CREATE OR REPLACE TYPE listePosologies AS TABLE OF Posologie;
/
--Je sais pas s'il faut mettre le SCOPE FOR
--Et je sais pas si c'est possible comme ça
--CREATE OR REPLACE TYPE tPosologie AS TABLE OF Posologie (SCOPE FOR (nomMolec) IS tMedicament);
CREATE OR REPLACE TYPE Traitement AS OBJECT (
idTraitement INTEGER,
......@@ -109,12 +129,11 @@ CREATE OR REPLACE TYPE Traitement AS OBJECT (
CREATE TABLE tTraitement OF Traitement (
PRIMARY KEY (idTraitement),
idVeterinaire NOT NULL,
FOREIGN KEY (idVeterinaire) REFERENCES Veterinaire (idVeterinaire)
);
FOREIGN KEY (idVeterinaire) REFERENCES Veterinaire(idVeterinaire)
) NESTED TABLE l_posologie STORE AS ntPosologies;
/
CREATE OR REPLACE TYPE RefTraitement AS OBJECT(refTraitement REF Traitement);
CREATE OR REPLACE TYPE RefTraitement AS OBJECT (refTraitement REF Traitement);
/
CREATE OR REPLACE TYPE ListeRefTraitement AS TABLE OF RefTraitement;
......@@ -124,11 +143,11 @@ CREATE OR REPLACE TYPE ListeRefTraitement AS TABLE OF RefTraitement;
CREATE OR REPLACE TYPE Animal AS OBJECT(
idAnimal INTEGER,
nom VARCHAR(20),
poids FLOAT,
taille FLOAT,
poids INTEGER,
taille INTEGER,
naissance DATE,
espece REF Espece,
l_traitements ListeRefTraitement
l_traitements ListeRefTraitement,
esp REF Espece
);
/
......@@ -137,9 +156,10 @@ CREATE TABLE tAnimal OF Animal (
nom NOT NULL,
poids NOT NULL,
taille NOT NULL,
SCOPE FOR (espece) IS tEspece,
CHECK (poids>0) AND (taille>0)
)NESTED TABLE l_traitements STORE AS traitements;
SCOPE FOR (esp) IS tEspece,
CHECK (poids>0),
CHECK (taille>0)
) NESTED TABLE l_traitements STORE AS ntTraitements;
/
CREATE OR REPLACE TYPE RefAnimal AS OBJECT (refAnimal REF Animal);
......@@ -150,13 +170,13 @@ CREATE OR REPLACE TYPE ListeRefAnimal AS TABLE OF RefAnimal;
CREATE TABLE Client (
idClient INTEGER NOT NULL PRIMARY KEY,
idClient INTEGER PRIMARY KEY,
nom VARCHAR (20) NOT NULL,
prenom VARCHAR(20) NOT NULL,
ddn DATE NOT NULL,
adresse VARCHAR(20) NOT NULL,
numero VARCHAR(10) NOT NULL,
CHECK (numero BETWEEN 0000000000 AND 0799999999),
CHECK (numero BETWEEN 0100000000 AND 0799999999),
l_animal ListeRefAnimal
)NESTED TABLE l_animal STORE AS animaux;
) NESTED TABLE l_animal STORE AS ntAnimaux;
/
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