Commit de685678 authored by Xiang Li's avatar Xiang Li
Browse files

Update RO_2.sql

parent ddcd0e04
......@@ -14,12 +14,12 @@ classe REF TClasse
/
CREATE TABLE Espece OF TEspece (
PRIMARY KEY (nom),
SCOPE FOR classe IS Classe
SCOPE FOR (classe) IS Classe
);
/
CREATE OR REPLACE TYPE TRefEspece AS OBJECT(espece REF TEspece);
/
CREATE TABLE RefEspece OF TRefEspece( SCOPE FOR espece IS Espece);
CREATE TABLE RefEspece OF TRefEspece( SCOPE FOR (espece) IS Espece);
/
CREATE OR REPLACE TYPE ListRefEspece AS TABLE OF TRefEspece;
/
......@@ -41,13 +41,13 @@ effets NOT NULL
/
CREATE OR REPLACE TYPE TPrescription AS OBJECT(
medicament REF TMedicament,
quantiteJour integer,
quantiteJour integer
);
/
CREATE TABLE Prescription OF TPrescription(
quantiteJour NOT NULL,
CHECK(quantiteJour > 0),
SCOPE FOR medicament IS Medicament
SCOPE FOR (medicament) IS Medicament
);
/
CREATE OR REPLACE TYPE ListPrescription AS TABLE OF TPrescription;
......@@ -60,26 +60,45 @@ id integer,
nom varchar2(255),
debut date,
duree integer,
prescriptions ListPrescription,
prescriptions ListPrescription
);
/
CREATE TABLE Traitement OF TTraitement(
PRIMARY KEY (id),
nom NOT NULL,
dubut NOT NULL,
debut NOT NULL,
duree NOT NULL,
CHECK (duree > 0)
) NESTED TABLE prescriptions STORE AS NT_Traitement_Prescriptions;
CREATE OR REPLACE TYPE TRefTraitement AS OBJECT(traitement REF TTraitement);
/
CREATE TABLE RefTraitement OF TRefTraitement( SCOPE FOR traitement IS Traitement);
CREATE TABLE RefTraitement OF TRefTraitement( SCOPE FOR (traitement) IS Traitement);
/
CREATE OR REPLACE TYPE ListRefTraitement AS TABLE OF TRefTraitement;
/
----------------------------------------------------------------
CREATE OR REPLACE TYPE TClients AS OBJECT (
id INTEGER,
telephone INTEGER,
nom VARCHAR(50),
prenom VARCHAR(50),
date_naissance DATE,
adresse VARCHAR(255)
);
CREATE TABLE Clients OF TCLients(
PRIMARY KEY (id),
telephone NOT NULL,
nom NOT NULL,
prenom NOT NULL,
date_naissance NOT NULL,
adresse NOT NULL,
CHECK (telephone > 100000000 AND telephone < 999999999)
);
/
CREATE OR REPLACE TYPE TAnimal AS OBJECT (
......@@ -90,6 +109,7 @@ CREATE OR REPLACE TYPE ListRefTraitement AS TABLE OF TRefTraitement;
date_naissance INTEGER,
espece REF TEspece,
traitements ListRefTraitement,
client REF TClients
);
/
CREATE TABLE Animal OF TAnimal(
......@@ -98,31 +118,14 @@ dernierPoids NOT NULL,
derniereTaille NOT NULL,
date_naissance NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (espece) REFERENCES Especes(nom),
CHECK (dernierPoids > 0),
CHECK (derniereTaille > 0),
CHECK (date_naissance > 1900),
client NOT NULL,
SCOPE FOR (client) IS Clients,
espece NOT NULL,
SCOPE FOR espece IS Espece
SCOPE FOR (espece) IS Espece
) NESTED TABLE traitements STORE AS NT_Animal_Traitements;
/
CREATE TYPE LAnimaux AS TABLE OF TAnimal;
/
CREATE TABLE Clients(
id INTEGER,
telephone INTEGER NOT NULL,
nom VARCHAR(50) NOT NULL,
prenom VARCHAR(50) NOT NULL,
date_naissance DATE NOT NULL,
adresse VARCHAR(255) NOT NULL,
animaux LAnimaux,
PRIMARY KEY (id),
CHECK (telephone > 100000000 AND telephone < 999999999),
CHECK (date_naissance BETWEEN DATE('1900-01-01') AND CURRENT_DATE)
);
/
CREATE TABLE Veterinaires(
id INTEGER,
......@@ -134,10 +137,8 @@ adresse VARCHAR(255) NOT NULL,
specialite REF TClasse NOT NULL,
traitements ListRefTraitement,
PRIMARY KEY (id),
FOREIGN KEY (specialite) REFERENCES Classes(nom),
CHECK (telephone > 100000000 AND telephone < 999999999),
CHECK (date_naissance BETWEEN DATE('1900-01-01') AND CURRENT_DATE),
SCOPE FOR specialite IS Classe
SCOPE FOR (specialite) IS Classe
) NESTED TABLE traitements STORE AS NT_Veterinaire_Traitements;
/
......@@ -150,9 +151,7 @@ date_naissance DATE NOT NULL,
adresse VARCHAR(255) NOT NULL,
specialite REF TClasse NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (specialite) REFERENCES Classes(nom),
CHECK (telephone > 100000000 AND telephone < 999999999),
CHECK (date_naissance BETWEEN DATE('1900-01-01') AND CURRENT_DATE),
SCOPE FOR specialite IS Classe
SCOPE FOR (specialite) IS Classe
);
/
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