From c72a5af8f348d21c4d1f46b5641d0d5024dd17fc Mon Sep 17 00:00:00 2001
From: qixiang peng <qixiang.peng@pc130-08.pedago.ensiie.fr>
Date: Tue, 12 Apr 2016 12:02:30 +0200
Subject: [PATCH] update create.sql

---
 create.sql | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/create.sql b/create.sql
index da8bf20..30aaca6 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
+   )
    
-- 
GitLab