Sql Serve - Cascade delete has multiple paths
I have two tables, results and results to be compared.
ComparedResults has two columns that refer to the primary key of the results table.
My problem is that if a record in the results is deleted, I want to delete all records in CompareResults that refer to the deleted record, no matter if it is one column or the other (and columns can refer to the same result row) ...
The row in the results can be deleted directly or through a cascade deletion caused by a deletion in the third table.
As a result of this, I can indicate that I need to disable cascading deletes and rewrite all cascading deletes to use triggers. Is this REALLY necessary? I would be willing to do a big restructuring of the database to avoid this, since my main area is OO programming and databases are supposed to "just work". However, it's hard to see how restructuring can help, since I would just move the problem ... Or am I missing something?
I am also a bit confused as to why my original design should be a problem for an Sql server ?!
Any comments are greatly appreciated and greatly appreciated!
Anders, Denmark
source to share