List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:January 11 2003 4:29am
Subject:Re: cannot get foreign keys to work
View as plain text  
At 18:45 +1100 1/10/03, Ben Mooney wrote:
>i have been using the following sql to try and get foreign keys 
>working, the table creation works fine but when i try and delete 
>data from the parent table it deletes as would normally happen in 
>mysql, also the desired results do not happen if i use RESTRICT.
>is this a problem to do with indexes???

In a sense, yes.  ON DELETE RESTRICT isn't implemented, I believe.


>
>DROP TABLE IF EXISTS parent;
>CREATE TABLE parent(id INT NOT NULL, name char(5), PRIMARY KEY (id)) 
>TYPE=INNODB;
>DROP TABLE IF EXISTS child;
>CREATE TABLE child(id INT NOT NULL, parent_id INT, INDEX par_ind 
>(parent_id), PRIMARY KEY (id),
>              FOREIGN KEY (parent_id) REFERENCES parent(id)
>              ON DELETE RESTRICT
>) TYPE=INNODB;
>
>insert into parent(name) values('asdfg');
>insert into child(parent_id) values(last_insert_id());
>
>
>system
>os x 10.2.3
>mysql 3.23.53-entropy.ch

Thread
cannot get foreign keys to workBen Mooney10 Jan
  • Re: cannot get foreign keys to workPaul DuBois11 Jan
Re: cannot get foreign keys to workAlan Hodgkinson10 Jan