Re: errno 150 - foreign key problems
Hi everyone,
I'm using MySQL 6.0.6-alpha for Windows (XP).
After reading forums, I couldn't find out what's the problem of my code.
That's my code:
CREATE TABLE Llar(
Id_llar integer,
Instruccions_ll varchar(1500),
CONSTRAINT Llar_pk_id_llar PRIMARY KEY (Id_llar),
CONSTRAINT Llar_fk_id_llar FOREIGN KEY (Id_llar) REFERENCES Producte(id_producte) ON DELETE CASCADE
);
CREATE TABLE Menatge(
Id_menatge integer,
Instruccions_me varchar(1500),
Tipus varchar(100) DEFAULT NULL,
Peces integer DEFAULT NULL,
CONSTRAINT Menatge_pk_id_me PRIMARY KEY (Id_menatge),
CONSTRAINT Menatge_fk_id_me FOREIGN KEY (Id_menatge) REFERENCES Llar(id_llar) ON DELETE CASCADE,
CONSTRAINT Menatge_fk_Instruccions_me FOREIGN KEY (Instruccions_me) REFERENCES Llar(Instruccions_ll) ON DELETE CASCADE
);
CREATE TABLE Moble(
Id_moble integer,
Instruccions_mo varchar(1500),
Dimensions varchar(50) DEFAULT NULL,
CONSTRAINT Moble_pk_id_moble PRIMARY KEY (Id_moble),
CONSTRAINT Moble_fk_id_moble FOREIGN KEY (Id_moble) REFERENCES Llar(id_llar) ON DELETE CASCADE,
CONSTRAINT Moble_fk_Instruccions_mo FOREIGN KEY (Instruccions_mo) REFERENCES Llar(Instruccions_ll) ON DELETE CASCADE
);
Just Menatge and Moble tables has herency of Llar. Both types are the same (varchar(1500)). And 'debuggin' I could see the problem is located on last line, for example, in Moble table: "CONSTRAINT Moble_fk_Instruccions_mo FOREIGN KEY (Instruccions_mo) REFERENCES Llar(Instruccions_ll) ON DELETE CASCADE"
So, we have the same problem on menatge. I have to say Llar table has herency too on other supertable called Producte. Maybe, Does SQL not support "double herency"?
Anyone have any idea to solve the problem?
Thanks a lot!.
Edited 1 time(s). Last edit at 10/07/2008 05:01PM by Nestor Martinez Arque.