maxim,
Tuesday, May 28, 2002, 4:47:13 PM, you wrote:

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

m> I have created two tables:

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

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

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

m>  delete from parent where id = "1"; 

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

ON DELETE CASCADE have worked since 3.23.50, 3.23.49 doesn't support
ON DELETE CASCADE. So, you should first delete rows from child table
that have parent_id=1 and then delete row from parent table.

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





-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Egor Egorov
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
       <___/   www.mysql.com



---------------------------------------------------------------------
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