On Delete Cascade
FOREIGN KEY (roll) REFERENCES students(roll) ON DELETE CASCADE means deleting Asha deletes her marks rows too. ON DELETE SET NULL sets marks.roll to NULL (column must allow NULL). Default is reject the delete.
Use CASCADE only when the child has no meaning without the parent (marks without a student). Don’t CASCADE a student to a payments table you must keep for audit.
Trap — CASCADE on every FK ‘so DELETE works’.
On the example next to this theory: On Delete Cascade — dELETE removes matching rows. TRUNCATE clears a whole table faster (MySQL).
Exam tip
ON DELETE CASCADE vs SET NULL vs RESTRICT.