MySQL Forums
Forum List  »  InnoDB

Foreign Key problems
Posted by: Paul Reiser
Date: September 12, 2014 10:46PM

Hello, I am new at using MySQL. I am using Innodb, and Workbench, and I am having foreign key problems. I am using Workbench, trying to make a simple genealogy database, with and PEOPLE table for people, PARENTS table for parent pairs, and SOURCES table for sources. I use this command:

INSERT INTO `mydb`.`PARENTS` (`PARE`, `SOUR`, `PARE1`, `PARE2`) VALUES ('McDowell-Mitchell', 'Source 1', 'Matthew McDowell', 'Mariah Mitchell');

and get this error:

ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`mydb`.`parents`, CONSTRAINT `PARE1` FOREIGN KEY (`PARE1`) REFERENCES `PEOPLE` (`INDI`) ON DELETE NO ACTION ON UPDATE NO ACTION)

I'm using the first and second columns on the PEOPLE table (INDI and SOUR) as a unique index, same for PARENTS (PARE and SOUR) and the foreign keys reference those columns, in the proper order (as shown by Workbench)

Maybe this is not enough information, but I will provide more if needed. Thanks for any help.

Paul Reiser

Options: ReplyQuote


Subject
Views
Written By
Posted
Foreign Key problems
1595
September 12, 2014 10:46PM
833
September 13, 2014 09:18PM
867
September 14, 2014 02:39AM
874
September 14, 2014 01:15PM
1143
September 14, 2014 07:40PM
898
September 14, 2014 09:37PM
899
September 14, 2014 11:07PM
954
September 15, 2014 07:26AM
1077
September 15, 2014 11:08AM
888
September 15, 2014 03:16PM


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.