Here's my database for a notification system (it has been stripped down for simplicity). When the a User is deleted I want the related Notification and UserEmail to be deleted but I get the constraint may cause cycles or multiple cascade paths error when I try to set the relationship to ON DELETE Cascade.
Unable to create relationship 'FK_Notification_TargetUser'.
Introducing FOREIGN KEY constraint 'FK_Notification_TargetUser' on table 'Notification' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Could not create constraint or index. See previous errors.
After doing some research my possible solutions are:
- Add an Instead Of Delete trigger to the User table and manually delete the child tables.
- Redesign the tables as suggested here: Foreign key constraint may cause cycles or multiple cascade paths? However I'm not quite sure what it would like in my case.
- Do a logical/soft delete. (recommended in the comments)
Any recommendations for what I should do?
Additional Resources: