Upload New File

parent 26d52e51
CREATE OR REPLACE TYPE ClasseEspece AS OBJECT (
nomClasse VARCHAR(20)
);
/
CREATE TABLE tClasseEspece OF ClasseEspece (
PRIMARY KEY (nomClasse)
);
/
CREATE TABLE Assistant (
idAssistant INTEGER NOT NULL 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)
);
/
CREATE TABLE Veterinaire (
idVeterinaire INTEGER NOT NULL 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
CHECK (numero BETWEEN 0000000000 AND 0799999999)
);
/
CREATE OR REPLACE TYPE Espece AS OBJECT (
espece VARCHAR(20),
classe REF ClasseEspece
);
/
CREATE TABLE tEspece OF Espece (
PRIMARY KEY (espece),
classe NOT NULL,
SCOPE FOR (classe) IS tClasseEspece
);
/
CREATE OR REPLACE TYPE RefEspece AS OBJECT (refEspece REF Espece);
/
CREATE OR REPLACE TYPE ListeRefEspece AS TABLE OF RefEspece;
/
CREATE OR REPLACE TYPE Medicament AS OBJECT(
nomMolec VARCHAR(20),
description VARCHAR(100),
especes ListeRefEspece,
--MEMBER FUNCTION espece_autoriser(espece IN|OUT VARCHAR(20)) RETURN BOOLEAN
);
/
/*
CREATE TYPE BODY Medicament
IS
MEMBER FUNCTION espece_autoriser(espece IN|OUT VARCHAR(20)) RETURN BOOLEAN
IS
BEGIN
r := SELECT COUT(*) FROM Medicament m
RETURN duree(SELF.debut,SELF.fin);
END;
END;
/
*/
CREATE TABLE tMedicament OF Medicament(
PRIMARY KEY (nomMolec),
description NOT NULL,
) NESTED TABLE especes STORE AS ntRefEspeces;
/
CREATE OR REPLACE TYPE Posologie AS OBJECT(
nomMolec REF Medicament,
debut DATE,
duree INTEGER,
nbJours INTEGER
);
/
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,
idVeterinaire INTEGER,
l_posologie listePosologies
);
/
CREATE TABLE tTraitement OF Traitement (
PRIMARY KEY (idTraitement),
idVeterinaire NOT NULL,
FOREIGN KEY (idVeterinaire) REFERENCES Veterinaire (idVeterinaire)
);
/
CREATE OR REPLACE TYPE RefTraitement AS OBJECT(refTraitement REF Traitement);
/
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,
naissance DATE,
espece REF Espece,
l_traitements ListeRefTraitement
);
/
CREATE TABLE tAnimal OF Animal (
PRIMARY KEY (idAnimal),
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;
/
CREATE OR REPLACE TYPE RefAnimal AS OBJECT (refAnimal REF Animal);
/
CREATE OR REPLACE TYPE ListeRefAnimal AS TABLE OF RefAnimal;
/
CREATE TABLE Client (
idClient INTEGER NOT NULL 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),
l_animal ListeRefAnimal
)NESTED TABLE l_animal STORE AS animaux;
/
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