Page 1 of 1
Cannot add or update a child row
Posted: Fri 05 Jun 2015 02:20
by marsheng
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 ?
Re: Cannot add or update a child row
Posted: Mon 08 Jun 2015 11:20
by alexa
Re: Cannot add or update a child row
Posted: Mon 08 Jun 2015 11:45
by marsheng
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.
Re: Cannot add or update a child row
Posted: Tue 09 Jun 2015 10:12
by alexa
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
Re: Cannot add or update a child row
Posted: Tue 09 Jun 2015 13:03
by alexa
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.
Re: Cannot add or update a child row
Posted: Tue 09 Jun 2015 20:34
by marsheng
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 ?
Re: Cannot add or update a child row
Posted: Wed 10 Jun 2015 11:35
by alexa
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.
Re: Cannot add or update a child row
Posted: Wed 10 Jun 2015 12:17
by marsheng
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.
Re: Cannot add or update a child row
Posted: Wed 10 Jun 2015 12:24
by marsheng
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.
Re: Cannot add or update a child row
Posted: Mon 15 Jun 2015 11:36
by alexa
We recommend you to refer to the following link for help
http://www.sqlinfo.net/mysql/mysql_Crea ... raints.php