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))
>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
>insert into parent(name) values('asdfg');
>insert into child(parent_id) values(last_insert_id());
>os x 10.2.3