Searched, but more confused now then when I started. I have 2 tables, AlertsTable
and AlertRecipientsTable
.
I'd like to add a cascaded delete that says when an AlertRecipientID
is deleted (the person was removed), I want it to automatically delete all records in the AlertsTable
that have that removed AlertRecipientID
.
AlertRecipientID
is a field in both tables. I still want to maintain ability to create an alert recipient without necessarily having an alert record set up for that recipient.
I'm confused on how to set up this constraint in MySQL. Have confirmed all my tables are configured as InnoDB and am using MySQL version 5.6.36-cll-lve.
Example:
AlertsTable:
AlertID AlertType AlertName AlertUserID AlertRecipientID AlertDateTimeAdded
1 1 Test 1 56 2018-01-07 14:29:39
AlertRecipientsTable:
AlertRecipientID AlertRecipientUserID AlertRecipientFirstName AlertRecipientLastName
56 1 John Doe
When I delete John Doe
with RecipientID
56
, I'd like it to delete the entry in the AlertsTable
named Test
.