MySQL Forums
Forum List  »  InnoDB

Re: errno 150 - foreign key problems
Posted by: Nestor Martinez Arque
Date: October 07, 2008 04:58PM

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.

Options: ReplyQuote


Subject
Views
Written By
Posted
58923
June 09, 2006 03:50PM
9715
December 07, 2006 07:28AM
Re: errno 150 - foreign key problems
7367
October 07, 2008 04:58PM
6250
October 07, 2008 05:55PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.