Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.
ON DELETE CASCADE is an optional clause in a foreign key declaration.
It is a foreign key integrity.It is of two type.cascade update and cascade delete.It stated that any time we can change/delete the value of a field of the primary key column and matching value in another column of another related table will be changed/deleted. Integrity constraints will be maintained.
A foreign key with cascade delete means that if a record in the parent table is deleted, then the corresponding records in the child table will automatically be deleted.
In SQL, cascade delete means if one of the parent record is deleted, then all the corresponding child record will be deleted automatically. In DBMS, there is also an operation called cascading roll back. That is, if a transaction T1 fails, then all other transactions depending on T1 must be roll backed. This is also a cascading effect.
It looks for master-child relationship constraint. so if you want to delete master without deleting the child data, it throws an error as exception. My 2 cents. Thanks.