In MySQL Workbench, how do you set up a cascading delete on a relationship?
I clicked the relationship line and clicked on properties but I do not see any mention of a cascading delete option.
ON DELETE CASCADE constraint is used in MySQL to delete the rows from the child table automatically, when the rows from the parent table are deleted. For example when a student registers in an online learning platform, then all the details of the student are recorded with their unique number/id.
Use the ON DELETE CASCADE option to specify whether you want rows deleted in a child table when corresponding rows are deleted in the parent table. If you do not specify cascading deletes, the default behavior of the database server prevents you from deleting data in a table if other tables reference it.
CASCADE : Delete or update the row from the parent table and automatically delete or update the matching rows in the child table. Both ON DELETE CASCADE and ON UPDATE CASCADE are supported.
MySQL ON UPDATE CASCADE ON UPDATE CASCADE clause in MySQL is used to update the matching records from the child table automatically when we update the rows in the parent table.
Right Click On Table -> Alter Table -> Foreign Keys Tab
Look at the upper-right corner "Foreign Key Options", there are two drop down boxes, one is to specify the delete action: "On Delete"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With