MySQL Forums
Forum List  »  InnoDB

on update cascade problem
Posted by: rhinoferoce9
Date: August 06, 2005 07:14PM

Hello all.

Here are simplified versions of my two tables:

CREATE TABLE players (name VARCHAR(50) PRIMARY KEY NOT NULL) TYPE = INNODB;

CREATE TABLE deaths (killer VARCHAR(50) NOT NULL, victim VARCHAR(50) NOT NULL, dateofdeath DATE NOT NULL, PRIMARY KEY (killer, victim, dateofdeath), INDEX (killer), FOREIGN KEY (killer) REFERENCES players (name) ON UPDATE CASCADE ON DELETE CASCADE, INDEX (victim), FOREIGN KEY (victim) REFERENCES players (name) ON UPDATE CASCADE ON DELETE CASCADE) TYPE = INNODB;

N.B.: When killer = victim, it means it was a suicide.

Let's say I insert Bob, Bill and Paul in players.

Now, in deaths I could have something like this:

Bob, Bill, 2005-08-01
Bob, Paul, 2005-08-01
Bill, Paul, 2005-08-02
Bill, Bob, 2005-08-02
...
Bob, Bob, 2005-08-03
...

If I decide to change Bill's name (in table players) there will not be any problem.

But if I decide to change Bob's name (in table players) I will get a 1216 error because of the record (Bob, Bob, 2005-08-03).

I am pretty sure my relational model is OK and I made the same experience in MS-Access and it worked.

Can someone help?

Options: ReplyQuote


Subject
Views
Written By
Posted
on update cascade problem
8645
August 06, 2005 07:14PM
3151
August 08, 2005 03:50AM
2565
August 09, 2005 02:38PM


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.