diff --git a/create.sql b/create.sql index da8bf20828f4b11c6a33b959adbe5cf649ef64f3..30aaca629b431d374e812cc2d6afc368614b664f 100644 --- a/create.sql +++ b/create.sql @@ -41,11 +41,12 @@ CREATE TABLE piece( ); CREATE TABLE representation( + n_representation INTEGER, nom_piece VARCHAR(100), horaire TIME, jour DATE, n_salle INTEGER, - CONSTRAINT pk_representation PRIMARY KEY (n_salle,horaire,jour), + CONSTRAINT pk_representation PRIMARY KEY (n_representation), CONSTRAINT fk_representation_salle FOREIGN KEY (n_salle) REFERENCES Salle ON DELETE RESTRICT, CONSTRAINT fk_representation_piece @@ -62,6 +63,18 @@ CREATE TABLE place( CONSTRAINT type_de_place CHECK (p_type IN ('vip', 'min','moyen')) ); - - +CREATE TABLE billet( + n_compte INTEGER, + n_place INTEGER, + n_representation INTEGER, + pourcentage DECIMAL, + CONSTRAINT pk_billet PRIMARY KEY (n_compte,n_place,n_representation), + CONSTRAINT type_de_place CHECK (p_type IN (0.5, 0.6, 0.8)), + CONSTRAINT fk_billet_place + FOREIGN KEY (n_place) REFERENCES place ON DELETE CASCADE, + CONSTRAINT fk_billet_compte + FOREIGN KEY (n_compte) REFERENCES compte_client ON DELETE CASCADE, + CONSTRAINT fk_billet_representation + FOREIGN KEY (n_representation) REFERENCES representation ON DELETE CASCADE + )