Commit a8b86548 authored by Ismail Merzougui's avatar Ismail Merzougui
Browse files

Ajout de contrainte sur les couples "DateEmprunt,code" et "DateRetourCode": un...

Ajout de contrainte sur les couples "DateEmprunt,code" et "DateRetourCode": un Document ne peut avoir été emprunté ou
rendu 2 fois à la même date à l'issu de 2 prêts différents
parent 54e8cb91
CREATE TYPE Etat as ENUm ('Abime','perdu','bon','neuf'); CREATE TYPE Etat as ENUm ('Abime','perdu','bon','neuf');
CREATE TYPE TypeDoc as ENUm ('Livre','Film','Musique'); CREATE TYPE TypeDoc as ENUm ('Livre','Film','Musique');
CREATE TABLE Adherent CREATE TABLE Adherent
( (
IdCarte VARCHAR(100) NOT NULL, IdCarte VARCHAR(100) NOT NULL,
...@@ -76,7 +76,9 @@ etatRetour ETAT NOT NULL, ...@@ -76,7 +76,9 @@ etatRetour ETAT NOT NULL,
PRIMARY KEY (code, Idcarte, dateEmprunt), PRIMARY KEY (code, Idcarte, dateEmprunt),
FOREIGN KEY(code) REFERENCES Document, FOREIGN KEY(code) REFERENCES Document,
FOREIGN KEY (Idcarte) REFERENCES Adherent, FOREIGN KEY (Idcarte) REFERENCES Adherent,
typeD TypeDoc typeD TypeDoc,
CONSTRAINT DateUnique UNIQUE(dateEmprunt,code),
CONSTRAINT DateUnique2 UNIQUE(dateRetour,code)
); );
...@@ -343,4 +345,5 @@ VALUES(49751676,00001,TO_DATE('20190310','YYYYMMDD'),'24:00:00',TO_DATE('2019031 ...@@ -343,4 +345,5 @@ VALUES(49751676,00001,TO_DATE('20190310','YYYYMMDD'),'24:00:00',TO_DATE('2019031
INSERT INTO Sanction (TypeSanction,DateDebut, Duree, DateFin, IdCarte) INSERT INTO Sanction (TypeSanction,DateDebut, Duree, DateFin, IdCarte)
VALUES('Suspension emprunt', TO_DATE('20190329','YYYYMMDD'), '24:00:00', TO_DATE('20190329','YYYYMMDD'), 776); VALUES('Suspension emprunt', TO_DATE('20190329','YYYYMMDD'), '24:00:00', TO_DATE('20190329','YYYYMMDD'), 776);
\ No newline at end of file
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