create_XML.sql 932 Bytes
Newer Older
Osvaldo Valdivia Salas's avatar
Osvaldo Valdivia Salas committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
CREATE TABLE Client(
  idClient INT NOT NULL,
	nom VARCHAR(30) NOT NULL,
	prenom VARCHAR(30) NOT NULL,
	ddn DATE NOT NULL,
	adresse VARCHAR(100) NOT NULL,
	numero INT NOT NULL,
	PRIMARY KEY(idClient),
  CHECK (numero >= 0100000000 AND numero <= 0799999999)
);

CREATE TABLE classeEspece(
  classeEspece VARCHAR(30) NOT NULL,
   PRIMARY KEY (classeEspece)
);


CREATE TABLE Espece(
  classe VARCHAR(30) NOT NULL,
  nomEspece VARCHAR(30) NOT NULL,
21
  PRIMARY KEY (nomEspece), 
22
  FOREIGN KEY(classe) REFERENCES classeEspece(classeEspece);
Osvaldo Valdivia Salas's avatar
Osvaldo Valdivia Salas committed
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
);

CREATE TABLE Animal (
  idAnimal INT NOT NULL,
  nom VARCHAR(30) NOT NULL,
  poids REAL NOT NULL,
  taille REAL NOT NULL,
  naissance DATE,
  traitements XMLTYPE,
  idClient INT NOT NULL,
  especeNom VARCHAR(30),
  PRIMARY KEY(idAnimal),
  FOREIGN KEY (idClient) REFERENCES Client(idClient),
  FOREIGN KEY (especeNom) REFERENCES Espece(nomEspece),
  CHECK (POIDS > 0),
  CHECK (TAILLE > 0)
);