MySQL Forums
Forum List  »  InnoDB

Newbie Q - Foreign Key issue
Posted by: Shaun Dean
Date: August 21, 2008 04:17AM

Let me preface all of this with the fact that I am completely new to MySQL - everything I know about it has come over the past 5 days or so. Lots of reading, lots of downloading, lots of hair pulling... you get the idea.

So I'm working on a database right now - 1 table [items] is the parent table for two others: [recipes] and [merchants]. I can get all of the data stuffed into the [items] table, and I can get the non-referenced data put into the other two. The problem comes when I try and set up the foreign keys in the [recipes] and [merchants] tables - I get the dreaded #1452 error. I'm working in Navicat as well, so I don't deal with the straight code - I know enough to know that I don't know THAT much. Both tables are also in InnoDB format, made sure of that before I posted anything.

Lets see... things that might be helpful to know:

CREATE TABLE items (
`items_id' varchar(255) NOT NULL,
`item_title` varchar(255) NOT NULL,
`itemtype_1` varchar(255) NOT NULL,
`itemtype_2' varchar(255),
PRIMARY KEY (`items_id`)
)

CREATE TABLE recipes (
`recipes_id` varchar(255) NOT NULL,
`skill_level` int(5) NOT NULL,
`ing amt 1` int(5) NOT NULL,
`item_title` varchar(255) NOT NULL,
`itemtype_1` varchar(255) NOT NULL,
`itemtype_2` varchar(255),
PRIMARY KEY (`recipes_id`)
)

Those, I've seen often enough to be able to type out from memory, but as far as the foreign key stuff, I let the program handle that. I'm trying to link `item_title`, `itemtype_1` and `itemtype_2` into the appropriate fields in the [items] table... but nothing I've yet done seems to be working. Help?

Options: ReplyQuote


Subject
Views
Written By
Posted
Newbie Q - Foreign Key issue
4550
August 21, 2008 04:17AM
3273
September 21, 2008 11:04AM


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.