Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Reference integrity

Author  Topic 

jung1975
Aged Yak Warrior

503 Posts

Posted - 2009-01-06 : 11:21:04
Is it a best database design practice to create both ON DELETE CASCADE and ON DELETE NO ACTION to implement Reference integrity?

or just ON DELETE NO ACTION ?



visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-06 : 11:36:22
didnt understand why you should do both. actually it depends on what your business rule suggest, if reqmnt is to automatically clear the refered records once master is cleared, then go for ON DELETE CASCADE else ON DELETE NO ACTION if you still want to perform the action if it doesnt violate constraint
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-06 : 12:33:20
There is no best practice on this. You can do it with the cascading constraints, or you could do it through code such as in a stored procedure. There are times where you can't implement a cascading constraint and must do it through code due to circular references.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2009-01-07 : 07:22:47
I'd recommend to use ON DELETE NO ACTION as it will make your code more understandable when stuff is not going on "behind the scenes"...

- Lumbago
Go to Top of Page
   

- Advertisement -