1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| CREATE TABLE Cinema(
CinemaId SMALLINT,
CinemaNom VARCHAR(50) NOT NULL,
CONSTRAINT Cinema_PK PRIMARY KEY(CinemaId)
);
CREATE TABLE Salle(
CinemaId SMALLINT,
SalleNo SMALLINT,
SalleNbPlaces SMALLINT NOT NULL,
CONSTRAINT Salle_PK PRIMARY KEY(CinemaId, SalleNo),
CONSTRAINT Salle_Cinema_FK FOREIGN KEY(CinemaId) REFERENCES Cinema(CinemaId)
);
CREATE TABLE Personne(
PersonneId INT,
PersonneNom VARCHAR(50) NOT NULL,
PersonnePrenom VARCHAR(50) NOT NULL,
CONSTRAINT Personne_PK PRIMARY KEY(PersonneId)
);
CREATE TABLE Ouvreuse(
PersonneId INT,
CONSTRAINT Ouvreuse_PK PRIMARY KEY(PersonneId),
CONSTRAINT Ouvreuse_Personne_FK FOREIGN KEY(PersonneId) REFERENCES Personne(PersonneId)
);
CREATE TABLE Operateur(
PersonneId INT,
CONSTRAINT Operateur_PK PRIMARY KEY(PersonneId),
CONSTRAINT Operateur_Personne_FK FOREIGN KEY(PersonneId) REFERENCES Personne(PersonneId)
);
CREATE TABLE Seance(
CinemaId SMALLINT,
SalleNo SMALLINT,
SeanceDate DATE,
SeanceHeure TIME,
PersonneId INT NOT NULL,
PersonneId_1 INT NOT NULL,
CONSTRAINT Seance_PK PRIMARY KEY(CinemaId, SalleNo, SeanceDate, SeanceHeure),
CONSTRAINT Seance_Salle_FK FOREIGN KEY(CinemaId, SalleNo) REFERENCES Salle(CinemaId, SalleNo),
CONSTRAINT Seance_Operateur_FK FOREIGN KEY(PersonneId) REFERENCES Operateur(PersonneId),
CONSTRAINT Seance_Ouvreuse_1_FK FOREIGN KEY(PersonneId_1) REFERENCES Ouvreuse(PersonneId)
); |
Partager