Guest User

Untitled

a guest
Jan 16th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. Drop database GestCom;
  2.  
  3.  
  4. Create Database GestCom;
  5.  
  6. use GestCom
  7.  
  8. Create Table Client (
  9. NumClient int (4) NOT Null AUTO_INCREMENT,
  10. Nom char (30) NOT Null,
  11. Prenom char (20),
  12. Adresse char (50),
  13. CodePostal char (5),
  14. Ville char (20),
  15. Tel char (10),
  16. PRIMARY KEY (NumClient)
  17. );
  18.  
  19.  
  20. Create Table Categorie (
  21. CodeCat int (4) NOT Null AUTO_INCREMENT,
  22. LibelleCat char (30),
  23. PRIMARY KEY (CodeCat)
  24. );
  25.  
  26.  
  27. Create Table Article (
  28. RefArt char (6) NOT Null PRIMARY KEY,
  29. DesignationArt char (30) NOT Null,
  30. PrixHTArt numeric (8,2) CHECK (PrixHTArt >= 0),
  31. CodeCat int (4) NOT Null REFERENCES Categorie (CodeCat)
  32. );
  33.  
  34.  
  35. Create Table Stock (
  36. RefArt char (5) NOT Null,
  37. Depot char (2) NOT Null,
  38. QteStock numeric (5) CHECK (QteStock >= 0),
  39. StockMini numeric (5) CHECK (StockMaxi >= StockMini),
  40. StockMaxi numeric (5) CHECK (StockMaxi >= StockMini),
  41. Primary Key (RefArt, Depot),
  42. FOREIGN KEY (RefArt) REFERENCES Article(RefArt)
  43. );
  44.  
  45.  
  46. Create Table Commande (
  47. NumCde int (4) PRIMARY KEY,
  48. DateCde timestamp DEFAULT now(),
  49. TauxRemise numeric (2) DEFAULT 0 CHECK (TauxRemise <= 50) ,
  50. EtatCde char(2) DEFAULT 'EC' CHECK (EtatCde IN ('EC', 'LP', 'LI', 'SO')),
  51. NumCli int NOT Null REFERENCES Client(NumCli)
  52. );
  53.  
  54.  
  55. Create Table LignesCde (
  56. NumCde int (4) NOT Null,
  57. NumLig int (2) NOT Null,
  58. QteCde int (3) DEFAULT 1 CHECK (QteCde >= 0),
  59. RefArt char (5) NOT Null,
  60. PRIMARY KEY (NumCde, NumLig),
  61. FOREIGN KEY (NumCde) REFERENCES Commande(NumCde),
  62. FOREIGN KEY (RefArt) REFERENCES Article(RefArt)
  63. );
  64.  
  65.  
  66. Create Table HistoFact (
  67. NumFact int (4) NOT Null AUTO_INCREMENT,
  68. DateFact timestamp DEFAULT now(),
  69. MontantFacture numeric (9,2) NOT Null,
  70. EtatFact char(2) DEFAULT 'NR' CHECK (EtatFact IN ('NR', 'RP', 'RC')),
  71. NumCde int (4),
  72. PRIMARY KEY (NumFact),
  73. FOREIGN KEY (NumCde) REFERENCES Commande(NumCde)
  74. );
  75.  
  76. show tables;
Add Comment
Please, Sign In to add comment