开发者

Sql Serve - Cascade delete has multiple paths

I have two tables, Results and ComparedResults.

ComparedResults has two columns which reference the primary key of the Results table.

My problem is that if a record in Results is deleted, I wish to delete all records in ComparedResults which reference the deleted record, regardless of whether it's one column or the other (and the columns may reference 开发者_开发问答the same Results row).

A row in Results may deleted directly or through cascade delete caused by deleting in a third table.

Googling this could indicate that I need to disable cascade delete and rewrite all cascade deletes to use triggers instead. Is that REALLY nessesary? I'd be prepared to do much restructuring of the database to avoid this, as my main area is OO programming, and databases should 'just work'. It is hard to see, however, how a restructuring could help as I would just move the problem around... Or am I missing something?

I am also a bit at a loss as to why my initial construct should even be a problem for the Sql Server?!

Any comments welcome and much appreciated!

Anders, Denmark


Would it be possible to split the ComparedResults into two tables?

Edit: You could then use a View to gather the results for showing? Or a join between the two tables?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜