Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1.  
  2. drop table if exists provenance;
  3. drop table if exists magasin;
  4. drop table if exists usine;
  5. drop table if exists produit;
  6.  
  7. create table produit (ref_prod integer primary key, nom_prod text not null, couleur text , poids integer);
  8. create table usine (ref_usine integer primary key, nom_usine text not null, ville text not null) ;
  9. create table magasin (ref_mag integer primary key, nom_mag text, ville text not null) ;
  10. create table provenance (ref_prod integer references produit, ref_usine integer references usine, ref_mag integer references magasin, quantite integer,
  11. constraint cle_prim primary key (ref_prod, ref_usine, ref_mag)) ;
  12.  
  13. -- remplissage des tables
  14.  
  15. INSERT INTO produit VALUES
  16. (1,'tabouret','rouge',5),
  17. (2,'evier','bleu',65),
  18. (3,'bureau','jaune',45),
  19. (4,'lampe a petrole','vert',15),
  20. (5,'ordinateur','rouge',10),
  21. (6,'telephone','bleu',8),
  22. (7,'tabouret','violet',1),
  23. (8,'evier','bleu',65),
  24. (9,'tabouret','orange',3),
  25. (10,'lampe halogene','rose',11),
  26. (11,'lampe a souder','noir',3),
  27. (12,'telephone','bleu',2),
  28. (13,'casse-noix','vert',1),
  29. (14,'casse-pied','marron',55),
  30. (15,'casse-oreille','violet',15);
  31.  
  32. INSERT INTO usine VALUES
  33. (109,'martin','Nantes'),
  34. (189,'leroux','Marseille'),
  35. (213,'dupont','Bordeaux'),
  36. (402,'peugeot','Toulouse'),
  37. (200,'peugeot','Marseille'),
  38. (302,'rover','Londres');
  39.  
  40. INSERT INTO magasin VALUES
  41. (14,'Stock10','Paris'),
  42. (16,'JaiTout','Marseille'),
  43. (18,'EnGros','Bordeaux'),
  44. (20,'PrixBas','Toulouse'),
  45. (22,'BasPrix','Marseille'),
  46. (24,'DuBon','Lyon'),
  47. (26,'DuBeau','Toulouse'),
  48. (28,'BasDeGamme','Dublin'),
  49. (30,'PasCher','Lyon'),
  50. (32,NULL,'Rennes'),
  51. (34,'NULL','Metz'),
  52. (36,'','Nantes');
  53.  
  54. INSERT INTO provenance VALUES
  55. (1,109,14,80),
  56. (1,109,16,100),
  57. (1,302,16,213),
  58. (2,189,30,213),
  59. (3,402,14,315),
  60. (4,200,18,985),
  61. (5,302,20,858),
  62. (6,213,16,315),
  63. (6,109,22,458),
  64. (7,109,16,213),
  65. (8,302,16,2000),
  66. (9,189,30,175),
  67. (10,402,14,100),
  68. (11,109,16,750),
  69. (11,302,16,100),
  70. (12,189,30,315),
  71. (12,200,16,589),
  72. (12,189,22,213),
  73. (13,402,14,499),
  74. (14,109,18,213),
  75. (15,189,20,1958),
  76. (15,189,16,333);
  77.  
  78.  
  79. -- copy produit from 'produit.dat' delimiter ','
  80. -- copy usine from 'usine.dat' delimiter ','
  81. -- copy magasin from 'magasin.dat' delimiter ','
  82. -- copy provenance from 'provenance.dat' delimiter ','
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement