422,734 Members | 1,335 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,734 IT Pros & Developers. It's quick & easy.

Mysql Using Navicat (error --- Foreign Key Fails)

P: 30
Hi I am new at ASP and MYSQL.

I am Using Navicat to access MYSQL database.

My Problem is when i create the foreign key in "Navicat" -it gives me this error.

1452-cannot add or update child row: a foreign key constraint fails....

Can any body help me - why am i getting this error - and how to fix it --

Is anything wrong --- I am trying since 2 days - no one knows how to fix it ?

Thanks,
Harsh (INDIA)
Jun 18 '07 #1
Share this Question
Share on Google+
4 Replies


10K+
P: 13,264
Hi I am new at ASP and MYSQL.

I am Using Navicat to access MYSQL database.

My Problem is when i create the foreign key in "Navicat" -it gives me this error.

1452-cannot add or update child row: a foreign key constraint fails....

Can any body help me - why am i getting this error - and how to fix it --

Is anything wrong --- I am trying since 2 days - no one knows how to fix it ?

Thanks,
Harsh (INDIA)
Apparently a foreign key constraint has failed. You can use

Expand|Select|Wrap|Line Numbers
  1. show innodb status; 
to show the last foreign key constraint that failed.
Jun 18 '07 #2

P: 30
Apparently a foreign key constraint has failed. You can use

Expand|Select|Wrap|Line Numbers
  1. show innodb status; 
to show the last foreign key constraint that failed.
I am sorry but i did not get it. I am using Navicat that is only GUI no code section.

Details: I want to do relationships with two tables. Players and Manufacturers

To do that in VWD. i have to assign the index key and foreign key in Navicat.

When i put the Index key it works but when i assign foreign key -- it ask me to put the reference table and choose the columns i want.

I choose - what i want and when i click ok i get this error that

Foreign Key constraint Fails:------


Thanks in advance,
Harsh
Jun 18 '07 #3

10K+
P: 13,264
I am sorry but i did not get it. I am using Navicat that is only GUI no code section.

Details: I want to do relationships with two tables. Players and Manufacturers

To do that in VWD. i have to assign the index key and foreign key in Navicat.

When i put the Index key it works but when i assign foreign key -- it ask me to put the reference table and choose the columns i want.

I choose - what i want and when i click ok i get this error that

Foreign Key constraint Fails:------


Thanks in advance,
Harsh
Well you have to understand your tables and the constraints that exist on them. Something is happening to a foreign key which is not allowed by one of your constraints. Check against your constratints.
Jun 18 '07 #4

P: 1
i meet the same error. I found my mistake is I inserted data, which not corresponding to both table before I create foreign key.

Ex: table a(id, name) with 2 record (1,peter); (2, flower)
table b(id, sex) with 3 record (1, male); (2, female); (3, male)
so when create foreign key for id of table b -> id of table a, record 3 of table b can't find any record of table a correspond.
Sep 9 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.