Hi all!

Question. I try to understand with " 4.3 Foreign key constraints " 
InnoDB Engine in MySQL-Max-3.23.50/MySQL-4.0.1. 
I use MySQL Max (InnoDB) 3.23.49 for Win2000

I have created two tables:

CREATE TABLE parent (id INT NOT NULL,
                      PRIMARY KEY (id)) TYPE=INNODB;
CREATE TABLE child (id INT, parent_id INT,
                      INDEX par_ind (parent_id),
                      FOREIGN KEY (parent_id) REFERENCES parent (id)
                      ON DELETE CASCADE
) TYPE=INNODB;

As I have understood, this design in cascade allows to delete record 
child table at removal(distance) of the line connected to it(her) parent table.
Or in other words to organize cascade removal(distance) of a line in child 
table at removal(distance) of the connected line in parent table.

Problem in the following. At attempt of removal(distance):

 delete from parent where id = "1"; 

There is a mistake: Error: Cannot delete a parent row: a foreign key 
constraint: fails.

Probably it is connected with blocking? I do not understand. How to remove 
a line from parent table so that the line child table has in cascade left 
connected on a key parent_id?


-- 
Best regards,
 maxim                          mailto:[EMAIL PROTECTED]


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to