MySQL Forums
Forum List  »  InnoDB

ON DELETE CASCADE
Posted by: Anette B
Date: September 11, 2007 09:14AM

Hi,
I have added my first two MySQL tables:
CREATE TABLE a (
id int NOT NULL AUTO_INCREMENT, PRIMARY KEY(id),
content varchar(20) NOT NULL,
done date NOT NULL
)
CREATE TABLE w (
id int NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
swedish varchar(20) NOT NULL,
english varchar(20) NOT NULL,
assignment_id int NOT NULL,
INDEX fk_assignmentid (assignment_id),
FOREIGN KEY (assignment_id) REFERENCES assignment(id) ON DELETE CASCADE
)

I have added data to both tables, so that the value in column assignment_id in table w corresponds to the value in column id in table a.
When I delete the record in table a, shouldn't the records in table w that has correspondning values also be deleted automatically?
That doesn't happen...

Options: ReplyQuote


Subject
Views
Written By
Posted
ON DELETE CASCADE
100329
September 11, 2007 09:14AM
30049
November 08, 2007 11:18AM
21984
November 26, 2007 12:37PM
24141
November 27, 2007 08:14AM
14988
September 01, 2008 09:39AM
14760
November 26, 2007 01:39PM
10210
November 27, 2007 12:43PM
10221
September 21, 2008 10:59AM
18613
November 17, 2007 09:09PM


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.