MySQL Forums
Forum List  »  Quality Assurance

Overzellous FK Constraint
Posted by: Mike Storey
Date: September 02, 2008 06:51PM

I'm sure that this is going to be a problem with the nut behind the keyboard. I'm having a specific insert record problem, stating that a FK Constraint is violated. Here is a screen capture of a few commands to show the problem.


mysql> select * from player where playerID = 12464;
+----------+--------------+-------------+--------+-------+-------+----------+--------+----------------+---------
| playerID | playerStatus | handle | prefix | fName | mName | lName | suffix | longName | address
+----------+--------------+-------------+--------+-------+-------+----------+--------+----------------+---------
| 12464 | P | pdga#-13087 | | Bruce | | Brakel   | | Bruce Brakel   |
+----------+--------------+-------------+--------+-------+-------+----------+--------+----------------+---------
1 row in set (0.00 sec)


mysql> select * from club where clubID = 1;
+--------+-----------+------------------------------------+---------------------------+-----------+-------------
| clubID | shortName | longName | url | contactID | customTable
+--------+-----------+------------------------------------+---------------------------+-----------+-------------
| 1 | PDGA | Professional Disc Golf Association | http://www.badcodisc.com/ | 1 |
+--------+-----------+------------------------------------+---------------------------+-----------+-------------
1 row in set (0.00 sec)


mysql> INSERT INTO affiliation (playerID, clubID, memberID, status) VALUES (1, 12464, '13087', 'Y');
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`discweb/affiliation`, CONSTRAINT `Affiliation_Club_FK` FOREIGN KEY (`clubID`) REFERENCES `club` (`clubID`) ON DELETE CASCADE)
mysql>

Options: ReplyQuote


Subject
Views
Written By
Posted
Overzellous FK Constraint
3321
September 02, 2008 06:51PM
1933
September 03, 2008 10:50AM


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.