What are the different ways to maintain data integrity in child table when the record is deleted in parent table?

MySQLMySQLi Database

When two tables are connected with Foreign key and data in the parent table is deleted, for which record exists in child table too, then followings are the ways to maintain data integrity −

On Delete Cascade

This option will remove the record from child table too if that value of the foreign key is deleted from the main table.

On Delete Null

 This option will set all the values in that record of child table as NULL, for which the value of the foreign key is deleted from the main table.

raja
Published on 19-Feb-2018 10:21:04
Advertisements