Bensallam

Untitled

Feb 28th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.86 KB | None | 0 0
  1. ------------------------------------------------------------
  2. --        Script Access
  3. ------------------------------------------------------------
  4.  
  5.  
  6. ------------------------------------------------------------
  7. -- Table: Client
  8. ------------------------------------------------------------
  9. CREATE TABLE Client(
  10.     Num_client     TEXT (25) NOT NULL ,
  11.     Nom_client     TEXT (50)  ,
  12.     Adresse_client TEXT (300)  ,
  13.     Tel_client     TEXT (15)  ,
  14.     CONSTRAINT prk_constraint_Client PRIMARY KEY (Num_client)
  15. );
  16.  
  17.  
  18. ------------------------------------------------------------
  19. -- Table: Produit
  20. ------------------------------------------------------------
  21. CREATE TABLE Produit(
  22.     Code_produit TEXT (25) NOT NULL ,
  23.     Nom_produit  TEXT (150)  ,
  24.     prix_public  MONEY   ,
  25.     CONSTRAINT prk_constraint_Produit PRIMARY KEY (Code_produit)
  26. );
  27.  
  28.  
  29. ------------------------------------------------------------
  30. -- Table: Facture
  31. ------------------------------------------------------------
  32. CREATE TABLE Facture(
  33.     ref_facture TEXT (25) NOT NULL ,
  34.     Date_achat  DATETIME   ,
  35.     Num_client  TEXT (25)  ,
  36.     CONSTRAINT prk_constraint_Facture PRIMARY KEY (ref_facture)
  37. );
  38.  
  39.  
  40. ------------------------------------------------------------
  41. -- Table: relation2
  42. ------------------------------------------------------------
  43. CREATE TABLE relation2(
  44.     qte_produit  DOUBLE   ,
  45.     prix_vente   MONEY   ,
  46.     Code_produit TEXT (25) NOT NULL ,
  47.     ref_facture  TEXT (25) NOT NULL ,
  48.     CONSTRAINT prk_constraint_relation2 PRIMARY KEY (Code_produit,ref_facture)
  49. );
  50.  
  51.  
  52.  
  53. ALTER TABLE Facture ADD CONSTRAINT FK_Facture_Num_client FOREIGN KEY (Num_client) REFERENCES Client(Num_client);
  54. ALTER TABLE relation2 ADD CONSTRAINT FK_relation2_Code_produit FOREIGN KEY (Code_produit) REFERENCES Produit(Code_produit);
  55. ALTER TABLE relation2 ADD CONSTRAINT FK_relation2_ref_facture FOREIGN KEY (ref_facture) REFERENCES Facture(ref_facture);
Advertisement
Add Comment
Please, Sign In to add comment