SQL Server - Foreign Key constraint may cause cycles or multiple cascade paths -
here's database notification system (it has been stripped down simplicity). when user deleted want related notification , useremail deleted constraint may cause cycles or multiple cascade paths error when try set relationship on delete cascade.
unable 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. not create constraint or index. see previous errors.
after doing research possible solutions are:
- add instead of delete trigger user table , manually delete child tables.
- redesign tables suggested here: foreign key constraint may cause cycles or multiple cascade paths? i'm not quite sure in case.
- do logical/soft delete. (recommended in comments)
any recommendations should do?
additional resources: