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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| CREATE TABLE film
(
num_film int NOT NULL IDENTITY
CONSTRAINT PK_film PRIMARY KEY
, num_realisateur int NOT NULL
-- CONSTRAINT FK_film__num_realisateur FOREIGN KEY (num_realisateur) REFERENCES dbo.realisateur
, titre nvarchar(150) NOT NULL
, genre int NOT NULL
-- CONSTRAINT FK_film__genre FOREIGN KEY(genre) REFERENCES dbo.genre ?
, annee smallint NOT NULL
CONSTRAINT CHK_film__annee CHECK (annee > 1900 AND annee < 2100)
)
GO
CREATE TABLE cinema
(
num_cinema int NOT NULL
CONSTRAINT PK_cinema PRIMARY KEY
, nom varchar(64) NOT NULL
, adresse varchar(256) NOT NULL
)
GO
CREATE TABLE individu
(
num_individu int NOT NULL
CONSTRAINT PK_individu PRIMARY KEY
, nom varchar(50) NOT NULL
, prenom varchar(50) NOT NULL
)
GO
CREATE TABLE jouer
(
num_jouer int NOT NULL IDENTITY
CONSTRAINT PK_jouer PRIMARY KEY
, num_individu int NOT NULL
CONSTRAINT FK_jouer__num_individu FOREIGN KEY(num_individu) REFERENCES dbo.individu
, num_film int NOT NULL
CONSTRAINT FK_jouer__num_film FOREIGN KEY(num_film) REFERENCES dbo.film
, role varchar(512)
, CONSTRAINT UQ_jouer__num_individu__num_film UNIQUE (num_individu, num_film)
)
GO
CREATE TABLE jour
(
jour date NOT NULL
CONSTRAINT PK_jour PRIMARY KEY
)
GO
CREATE TABLE projection
(
num_projection int NOT NULL
CONSTRAINT PK_projection PRIMARY KEY
, num_cinema int NOT NULL
CONSTRAINT FK_projection__num_cinema FOREIGN KEY(num_cinema) REFERENCES dbo.cinema
, num_film int NOT NULL
CONSTRAINT FK_projection__num_film FOREIGN KEY(num_film) REFERENCES dbo.film
, jour date NOT NULL
CONSTRAINT FK_projection__jour FOREIGN KEY(jour) REFERENCES dbo.jour
, CONSTRAINT UQ_projection__num_cinema__num_film__jour UNIQUE (num_cinema, num_film, jour)
) |
Partager