I have two tables like this:
CREATE TABLE parent
(
par_id INT NOT NULL,
PRIMARY KEY (par_id)
) ENGINE = INNODB;
CREATE TABLE child
(
par_id INT NOT NULL,
child_id INT NOT NULL,
PRIMARY KEY (par_id, child_id),
FOREIGN KEY (par_id) REFERENCES parent (par_id)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE = INNODB;
When I delete anything from the parent table, it deletes everything related to the parent table. This is OK.
But when I delete anything from the child table, it does delete it.
It was not supposed to because the foreing key.
What do I need to do to only be able to delete from the parent table?
I would like to have a message saying that record can not delete because thats a child table.
Thanks
Roger.