2011-04-08 74 views
2

我创建的电子商务数据库MYSQL问题错误#1005

我有一两件事做错了,我不知道为什么..显然我的表(succursaleProduit)中的一个不能创造

错误 - >#1005 - Can't create table 'ordidepot.succursaleproduit' (errno: 150)

这是我的SQL文件的内容

  CREATE TABLE Adresse 
     (
     idAdresse INT(10) AUTO_INCREMENT NOT NULL, 
     rue   VARCHAR(30), 
     ville  VARCHAR(30), 
     codePostal VARCHAR(7), 
     civic  INT(10), 
     app   VARCHAR(10), 
     CONSTRAINT Adresse_idAdresse_PK PRIMARY KEY (idAdresse) 
     ); 



     CREATE TABLE Client(
     idClient INT(10) AUTO_INCREMENT NOT NULL, 
     idAdresse INT(10), 
     nom   VARCHAR(50), 
     prenom  VARCHAR(50), 
     email  VARCHAR(50), 
     telephone VARCHAR(50), 
     cellullaire VARCHAR(50), 
     motDePasse VARCHAR(50), 
     Constraint Client_idClient_PK Primary Key(idClient), 
     Constraint Client_idAdresse Foreign Key(idAdresse) references Adresse(idAdresse) 
     ON DELETE CASCADE ON UPDATE CASCADE 

     ); 



     CREATE TABLE Sucursale(
     idSucursale INT(10) AUTO_INCREMENT NOT NULL, 
     idAdresse INT(10), 
     nom   VARCHAR(50), 
     email  VARCHAR(50), 
     telephone VARCHAR(50), 
     cellullaire VARCHAR(50), 
     Constraint Sucursale_idSucursale_PK Primary Key(idSucursale), 
     Constraint Sucursale_idAdresse Foreign Key(idAdresse) references Adresse(idAdresse) 
     ON DELETE CASCADE ON UPDATE CASCADE 
     ); 


     CREATE TABLE Panier(
     idPanier INT(10) AUTO_INCREMENT NOT NULL, 
     idClient INT(10), 
     Constraint Panier_idPanier_PK Primary Key(idPanier), 
     Constraint Panier_idClient Foreign Key(idClient) references Client(idClient) 
     ON DELETE CASCADE ON UPDATE CASCADE 
     ); 

     CREATE TABLE Produit(
     idProduit  INT(10) AUTO_INCREMENT NOT NULL, 
     nomProduit  VARCHAR(50), 
     description  VARCHAR(100), 
     nomFournisseur   VARCHAR(50), 
     prixRevient  INT(10), 
     prixVente  INT(10), 

     nomFichierImage   VARCHAR(50), 
     Constraint Produit_idProduit_PK Primary Key(idProduit) 
     ); 

     CREATE TABLE Rabais(
     idRabais INT(10) AUTO_INCREMENT NOT NULL, 
     idProduit INT(10), 
     pourcentage INT(10), 
     dateDebut Date, 
     dateFin  Date, 
     Constraint Rabais_idRabais_PK Primary Key(idRabais), 
     Constraint Rabais_idProduit Foreign Key(idProduit) references Produit(idProduit) 
     ON DELETE CASCADE ON UPDATE CASCADE 
     ); 

     CREATE TABLE Systeme(
     idSysteme INT(10) AUTO_INCREMENT NOT NULL, 
     idProduit INT(10), 
     Constraint Systeme_idSysteme_PK Primary Key(idSysteme), 
     Constraint Systeme_idProduit Foreign Key(idProduit) references Produit(idProduit) 
     ON DELETE CASCADE ON UPDATE CASCADE 
     ); 

     CREATE TABLE Jeux(
     idJeux  INT(10) AUTO_INCREMENT NOT NULL, 
     idProduit INT(10), 
     typeJeux VARCHAR(50), 
     Constraint Jeux_idJeux_PK Primary Key(idJeux), 
     Constraint Jeux_idProduit Foreign Key(idProduit) references Produit(idProduit) 
     ON DELETE CASCADE ON UPDATE CASCADE 
     ); 

     CREATE TABLE Pieces(
     idPieces INT(10) AUTO_INCREMENT NOT NULL, 
     idProduit INT(10), 
     categorie VARCHAR(50), 
     Constraint Pieces_idPieces_PK Primary Key(idPieces), 
     Constraint Pieces_idProduit Foreign Key(idProduit) references Produit(idProduit) 
     ON DELETE CASCADE ON UPDATE CASCADE 
     ); 

     CREATE TABLE SystemeComplet(
     idSystemeComplet  INT(10) AUTO_INCREMENT NOT NULL, 
     idProduit   INT(10), 
     quantite   INT(10), 
     Constraint SystemeComplet_idSystemeComplet_PK Primary Key(idSystemeComplet), 
     Constraint SystemeComplet_idProduit Foreign Key(idProduit) references Produit(idProduit) 
     ON DELETE CASCADE ON UPDATE CASCADE 
     ); 

     CREATE TABLE ProgUtilitaire(
     idProgUtilitaire   INT(10) AUTO_INCREMENT NOT NULL, 
     idProduit    INT(10), 
     version     VARCHAR(50), 
     Constraint ProgUtilitaire_idProgUtilitaire_PK Primary Key(idProgUtilitaire), 
     Constraint ProgUtilitaire_idProduit Foreign Key(idProduit) references Produit(idProduit) 
     ON DELETE CASCADE ON UPDATE CASCADE 
     ); 



     CREATE TABLE ClientAdresse 
     (
     idClient INT(10), 
     idAdresse INT(10), 
     Constraint ClientAdresse_idClient_FK Foreign Key(idClient) References Client(idClient) 
     ON DELETE CASCADE ON UPDATE CASCADE, 
     Constraint ClientAdresse_idAdresse_FK Foreign Key(idAdresse) References Adresse(idAdresse) 
     ON DELETE CASCADE ON UPDATE CASCADE 
     ); 

     CREATE TABLE SuccursaleProduit 
     (
     idSuccursale  INT(10), 
     idProduit  INT(10), 
     quantite  INT(10), 
     Constraint SuccursaleProduit_idSuccursale_FK Foreign Key(idSuccursale) References Succursale(idSuccursale) 
     ON DELETE CASCADE ON UPDATE CASCADE, 
     Constraint SuccursaleProduit_idProduit_FK Foreign Key(idProduit) References Produit(idProduit) 
     ON DELETE CASCADE ON UPDATE CASCADE 
     ); 

     CREATE TABLE SCProgU 
     (
     idProgUtilitaire INT(10), 
     idSystemeComplet INT(10), 
     Constraint SCProgU_idProgUtilitaire_FK Foreign Key(idProgUtilitaire) References ProgUtilitaire(idProgUtilitaire) 
     ON DELETE CASCADE ON UPDATE CASCADE, 
     Constraint SCProgU_idSystemeComplet_FK Foreign Key(idSystemeComplet) References SystemeComplet(idSystemeComplet) 
     ON DELETE CASCADE ON UPDATE CASCADE 
     ); 

     CREATE TABLE SCPieces 
     (
     idPieces  INT(10), 
     idSystemeComplet INT(10), 
     Constraint SCPieces_idPieces_FK Foreign Key(idPieces) References Pieces(idPieces) 
     ON DELETE CASCADE ON UPDATE CASCADE, 
     Constraint SCPieces_idSystemeComplet_FK Foreign Key(idSystemeComplet) References SystemeComplet(idSystemeComplet) 
     ON DELETE CASCADE ON UPDATE CASCADE 
     ); 

     INSERT INTO Adresse (rue, ville, codePostal, civic, app) VALUES 
     ('asdf', 'montreal', 'H2A7J9', 1245, '1'), 
     ('qwe', 'montreal', 'K2A2L9', 15, '5'); 


     INSERT INTO Sucursale (idAdresse, nom, email, telephone, cellullaire) VALUES 
     (1, 'DADA', '[email protected]', '5145489632', '5145245685'); 

     INSERT INTO Sucursale (idAdresse, nom, email, telephone, cellullaire) VALUES 
     (2, 'DADA', '[email protected]', '5145489632', '5145245685'); 

     INSERT INTO Produit(nomProduit,description,nomFournisseur,prixRevient,prixVente,nomFichierImage) VALUES ('PC DE BUREAU','pc de choix','COMPAQ',300,250,''); 
     INSERT INTO Produit(nomProduit,description,nomFournisseur,prixRevient,prixVente,nomFichierImage) VALUES ('LAPTOP','LAPTOP de choix','HP',300,250,''); 
     INSERT INTO Pieces(idProduit,categorie) VALUES(1,'ordinateur'); 
     INSERT INTO Pieces(idProduit,categorie) VALUES(2,'ordinateur portable'); 

感谢所有

+0

此表格是'Succursale'和'Produit' – ThorDozer 2011-04-08 03:28:52

+0

之间的链接。它为我工作。你运行的是哪个版本的mysql? – squawknull 2011-04-08 03:35:04

+0

MYSQL版本5.5.8 – ThorDozer 2011-04-08 03:36:07

回答

1

看来这是Mysql 5.5中的一个特定问题。它似乎没有发生与我的5.1版本。尝试降级,看看是否有帮助。

相关问题