MySQL Forums
Forum List  »  InnoDB

Re: foreign key problem!!
Posted by: scuba
Date: November 04, 2005 05:29PM

He Jan, thanks for helping - here an example code pointing out my problem. Insert identical data into both tables:

ID | NAME
1 | Karen
2 | John
3 | Maria
4 | Kevin

Now change John in parent into Maria. Child will change into Maria too - so far so good. Now go back to parent and change Maria on id 2 into Thomas. Child now changes both Marias into Thomas instead of just the one on id 2. I really need to find a solution on that - if there is one. Thanks for any help in advance!!!

CREATE TABLE parent
(
id INT NOT NULL,
name VARCHAR(10) NULL,
PRIMARY KEY (id),
INDEX name_ind (name)
)
TYPE=INNODB


CREATE TABLE child
(
id INT NOT NULL,
name VARCHAR(10) NULL,
INDEX id_index (id),
INDEX name_index (name),
FOREIGN KEY (id) REFERENCES parent(id),
FOREIGN KEY (name) REFERENCES parent(name)
ON DELETE CASCADE
ON UPDATE CASCADE
)
TYPE=INNODB;

Options: ReplyQuote


Subject
Views
Written By
Posted
2302
November 03, 2005 06:20PM
1474
November 04, 2005 12:09AM
Re: foreign key problem!!
1510
November 04, 2005 05:29PM
1546
November 04, 2005 05:51PM
1517
November 07, 2005 12:08AM
1442
November 07, 2005 08:52AM
1493
November 10, 2005 01:12AM
1508
November 11, 2005 01:00PM


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.