A foreign key with cascading deletion means that if an entry in the parent table is deleted, the corresponding entries in the child table will be automatically deleted. This is called cascading deletion.
You say the opposite, this does not mean that if you delete from the child table, the records will be deleted from the parent table.
UPDATE 1:
ON DELETE CASCADE - indicate whether you want to delete rows in the child table when the corresponding columns are deleted in the parent table. If you do not specify cascading deletions, the default behavior of the database server by default does not allow you to delete data in a table if it refers to other tables.
If you specify this parameter, later, when you delete a row in the parent table, the database server will also delete any rows associated with this row (foreign keys) in the child table. The main advantage of the cascade-delete function is that it allows you to reduce the number of SQL statements needed to perform the delete actions.
So, all that happens when you delete rows from the parent table, and not from the child table.
So, in your case, when the user deletes entries from the CATs table, the rows will be deleted from the book table. :)
Hope this helps you :)
Mari Jan 03 '13 at 14:58 2013-01-03 14:58
source share