use master GO if exists(SELECT Name from master..sysdatabases WHERE Name LIKE 'Magasin') BEGIN print '############################################################' print '# Suppression de la base de donnée Magasin existante #' print '############################################################' Drop Database Magasin END print '############################################################' print '# Création de la base de donnée Magasin #' print '############################################################' GO Create DataBase Magasin GO /*On se positionne sur la table crée*/ Use Magasin /*On crée les tables de la BD*/ /* Création table T_Clients */ GO print '############################################################' print '# Création de la table T_Clients #' print '############################################################' GO Create table T_Categories ( primary key ([Cat_No]), [Cat_No] integer identity(1000,1) unique NOT NULL, [Cat_Nom] VarChar(20) NOT NULL, ) GO Create table T_Produits ( primary key ([Pro_No],[Cat_No]), [Pro_No] integer identity(1000,1) unique NOT NULL, [Pro_Nom] VarChar(50) NOT NULL, [Pro_Qte] int NOT NULL, [Pro_Prix] Real NOT NULL, [Cat_No] integer NOT NULL, ) GO /*************************************/ /* Intégritée référentielle */ /*************************************/ print '############################################################' print '# Création de lintégritée référentielle #' print '############################################################' ALTER TABLE [T_Produits] ADD CONSTRAINT [FK_Categorie_IDe001] foreign key ([Cat_No]) references [T_Produits]([Pro_No]) GO /*************************************/ /*Ici on ajoute des entrées a la BD */ /*************************************/ print '############################################################' print '# Ajout de champs pour la table T_Categories #' print '############################################################' insert into [T_Categories] VALUES ('Curling') insert into [T_Categories] VALUES ('Patin') insert into [T_Categories] VALUES ('Snowboard') insert into [T_Categories] VALUES ('Peche') insert into [T_Categories] VALUES ('Raquette') insert into [T_Categories] VALUES ('Football') GO print '############################################################' print '# Ajout de champs pour la table T_Produits #' print '############################################################' insert into [T_Produits] VALUES ('Balai Transformer 8-ender',34,73.99,1000) insert into [T_Produits] VALUES ('Chaussures de curling Asham',12,89.99,1000) insert into [T_Produits] VALUES ('Patin Senior Bauer Vapor Pro',16,219.99,1001) insert into [T_Produits] VALUES ('Patin Mission Pure C4',49,199.99,1001) insert into [T_Produits] VALUES ('Patin Easton Synergy, homme',34,199.99,1001) insert into [T_Produits] VALUES ('Patins Nike Q4 pour juniors',58,139.99,1001) insert into [T_Produits] VALUES ('Patin Bauer Vapor Pro',19,159.99,1001) insert into [T_Produits] VALUES ('Planche à neige Pro 145',14,159.99,1002) insert into [T_Produits] VALUES ('Bottes pour planche à neige',37,79.99,1002) insert into [T_Produits] VALUES ('Planche à neige Echos 144 H2O',24,58.99,1002) insert into [T_Produits] VALUES ('Canne à lancer, série Izumi',44,79.99,1003) insert into [T_Produits] VALUES ('Canne à lancer léger Shimano Convergence',17,69.99,1003) insert into [T_Produits] VALUES ('Canne Rhino en 3 pièces, 5 pi',27,28.99,1003) insert into [T_Produits] VALUES ('Raquettes Tubbs, 36 po',14,279.99,1004) insert into [T_Produits] VALUES ('Raquettes Tubbs Adventure',24,239.99,1004) insert into [T_Produits] VALUES ('Raquettes Atlas en aluminium',32,199.99,1004) insert into [T_Produits] VALUES ('Bâtons réglables pour raquettes Atlas',90,64.99,1004) insert into [T_Produits] VALUES ('Bâtons Poweridge, 2 pces',46,59.99,1004) insert into [T_Produits] VALUES ('Fixations de raquettes',48,22.99,1004) insert into [T_Produits] VALUES ('Ballon de football Nike Cage Grip',18,34.99,1005) insert into [T_Produits] VALUES ('Ballon de football Wilson NFL en composite',30,29.99,1005) insert into [T_Produits] VALUES ('Ballon de football Nike 1000',4,29.99,1005) insert into [T_Produits] VALUES ('Ballon de football Wilson',17,15.99,1005)