Cannot add or update a child row

Discussion of open issues, suggestions and bugs regarding database management and administration tools for MySQL
Post Reply
marsheng
Posts: 62
Joined: Thu 10 May 2012 10:51

Cannot add or update a child row

Post by marsheng » Fri 05 Jun 2015 02:20

I'm slowly getting my way round Studio express. I have managed to link several tables but he last one crashes.

Messages
To create a foreign key 'FK_mnz_members_incident_MNZID', a new unique key will be added to the referenced table 'clubs_register.incident'.

Do you want to continue?. Yes

Cannot add or update a child row: a foreign key constraint fails (`clubs_register`.`#sql-aeb_14f0`, CONSTRAINT `FK_mnz_members_incident_MNZID` FOREIGN KEY (`MNZID`) REFERENCES `incident` (`MNZID`) ON DELETE NO ACTION ON UPDATE NO ACTION)

I have checked the field types and length and that all the data in incident table has a corresponding value in mnz_members so I'm stuck on what to do.

Where do I find what sql-aeb_14f0 means ?

alexa

Re: Cannot add or update a child row

Post by alexa » Mon 08 Jun 2015 11:20

We recommend you to see the following http://stackoverflow.com/questions/2165 ... aint-fails

marsheng
Posts: 62
Joined: Thu 10 May 2012 10:51

Re: Cannot add or update a child row

Post by marsheng » Mon 08 Jun 2015 11:45

I looks like whatever engine was use to create the package is use universally. I downloaded another software suppliers program and got exactly the same message.

I just with the error was more friendly eg ID don't match , records missing, duplicate entries etc. then we would know where to look.
I have since managed to get a bit further with your studio program.

On the database diagram, how do I change a relationship from one to one, one to many, many to many. This was mostly my issue. The program tried to make a one to one when I needed one to many and I can't seem to change this.

alexa

Re: Cannot add or update a child row

Post by alexa » Tue 09 Jun 2015 10:12

Could you please provide us the CREATE definitions of the parent and child tables?

You can send a reply straight to our support system at supportATdevartDOTcom and alexaATdevartDOTcom

alexa

Re: Cannot add or update a child row

Post by alexa » Tue 09 Jun 2015 13:03

Thank you for the reply.

In order to avoid the error "Cannot add or update a child row: a foreign key constraint fails (`clubs_register`.`#sql-aeb_14f0`, CONSTRAINT `FK_mnz_members_incident_MNZID` FOREIGN KEY (`MNZID`) REFERENCES `incident` (`MNZID`) ON DELETE NO ACTION ON UPDATE NO ACTION)", please check whether there are non-unique values in the MNZID column of the incident table.

In case you are attempting to create the one to one relation, there must be unique values in the column of the parent table, because it will be referenced by the primary key column of the child table.

marsheng
Posts: 62
Joined: Thu 10 May 2012 10:51

Re: Cannot add or update a child row

Post by marsheng » Tue 09 Jun 2015 20:34

Can you please change the error message say that.

Change "#sql-aeb_14f0" to say "there must be unique values in the column of the parent table"

But I still have the question, how am I supposed to specify whether I wanted a one to one or one to many ?

alexa

Re: Cannot add or update a child row

Post by alexa » Wed 10 Jun 2015 11:35

Unfortunately, we can't change this since this is the error returned by the MySQL server itself.

On the database diagram of dbForge, relationships between objects are generated automatically depending on the CREATE definitions of tables and their column types. You would need to modify the table structures in order the table relationships to be changed.

marsheng
Posts: 62
Joined: Thu 10 May 2012 10:51

Re: Cannot add or update a child row

Post by marsheng » Wed 10 Jun 2015 12:17

Surly you should b able to interpret the SQL message and give a useful translation.

Alternatively, were can I find the SQL error message descriptions.

Searching on "aeb_14f0" only brings up my post. At least this will help the next person with this problem.

marsheng
Posts: 62
Joined: Thu 10 May 2012 10:51

Re: Cannot add or update a child row

Post by marsheng » Wed 10 Jun 2015 12:24

The reason for using the Studio Express is because I don't want to do SQL coding. I think that you need to add the various relationships options as icons on the toolbar. Whichever relationship we want, we select and your software then modifies the CREATE statement to suit. Even the option to click on a relationship link and change the option would be great.

Interpret the SQL errors to something meaningful and you will have a great tool.

alexa

Re: Cannot add or update a child row

Post by alexa » Mon 15 Jun 2015 11:36

We recommend you to refer to the following link for help http://www.sqlinfo.net/mysql/mysql_Crea ... raints.php

Post Reply