3 messages in com.mysql.lists.mysqlcreate table with foreign key
FromSent OnAttachments
Scott Purcell29 Apr 2005 09:32 
SGr...@unimin.com29 Apr 2005 09:39 
mfat...@free.fr29 Apr 2005 09:50 
Subject:create table with foreign key
From:Scott Purcell (spur@vertisinc.com)
Date:04/29/2005 09:32:34 AM
List:com.mysql.lists.mysql

Hello,

I have this simple table of unique items.

CREATE TABLE ITEM ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, manufacturer_id varchar(50), ) TYPE=InnoDB;

Foreach item, I can have 1 to many assets. So I am trying to use this: CREATE TABLE ITEM_ASSET_REL ( id INT, asset_id VARCHAR(10), FOREIGN KEY(id) references ITEM(id) on DELETE CASCADE ) TYPE=InnoDB;

But I get the error 150. Now if I make the 'item_asset_rel' id UNIQUE, then it
is happy. But that defeats my purpose of having many asset_id to one item.

Can anyone please, please help.

Thanks,

Vertis is the premier provider of targeted advertising, media, and marketing services that drive consumers to marketers more effectively.