Referential Integrity VS Cascade Deletes

Referential Integrity VS Cascade Deletes

Post by Kirby Scarboroug » Fri, 02 Feb 2001 13:03:13



I am looking for opinions on the issue of Referential Integrity vs Using
Triggers to Simulate Cascade Deletes, since SQL Server 7 doesn't allow both.
Do you sacrifice referential integrity and use triggers - or do you maintain
referential integrity at the database level and use stored procedures to
perform cascade deletes? Even though you can theoretically (with much work)
create enough triggers to maintain referential integrity, I have read that
triggers are slower than using foreign key constraints.  Also, security is
an issue since you can dissallow all deletes at the table level and only
give permission to the stored procedure. The downside to the stored
procedure method is the obvious "mess" it creates. This has been a huge
company discussion and any opinions are appreciated.
Thanks,

 
 
 

Referential Integrity VS Cascade Deletes

Post by Dan Guzma » Fri, 02 Feb 2001 14:15:57


Coding the cascade function in triggers or procs is about the same level of
development effort.  I don't see procs being any messier than triggers.

Personally, I prefer DRI and would use procs for this functionality under
SQL 7.  Better yet, upgrade to SQL Server 2000 since it provides cascaded
functions via DRI.

Hope this helps.

-----------------------
SQL FAQ links (courtesy  Neil Pike):

 http://forumsb.compuserve.com/gvforums/UK/default.asp?SRV=MSDevApps
 (faqxxx.zip in lib 7)
 or www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
 or www.sqlserverfaq.com
 or www.mssqlserver.com/faq
-----------------------


> I am looking for opinions on the issue of Referential Integrity vs Using
> Triggers to Simulate Cascade Deletes, since SQL Server 7 doesn't allow
both.
> Do you sacrifice referential integrity and use triggers - or do you
maintain
> referential integrity at the database level and use stored procedures to
> perform cascade deletes? Even though you can theoretically (with much
work)
> create enough triggers to maintain referential integrity, I have read that
> triggers are slower than using foreign key constraints.  Also, security is
> an issue since you can dissallow all deletes at the table level and only
> give permission to the stored procedure. The downside to the stored
> procedure method is the obvious "mess" it creates. This has been a huge
> company discussion and any opinions are appreciated.
> Thanks,



 
 
 

Referential Integrity VS Cascade Deletes

Post by Kirby Scarboroug » Sat, 03 Feb 2001 06:03:24


Thanks Dan, I agree.
Kirby

>Coding the cascade function in triggers or procs is about the same level of
>development effort.  I don't see procs being any messier than triggers.

>Personally, I prefer DRI and would use procs for this functionality under
>SQL 7.  Better yet, upgrade to SQL Server 2000 since it provides cascaded
>functions via DRI.

>Hope this helps.

>-----------------------

 
 
 

1. SQL Server 7 Referential Integrity Check + Cascading deletes?

I have SQL server 6.5 and it won't do both a foriegn key and a
cascading delete... It does on or the other.  I was wondering if this
is fixed in SQL Server 7.

IE:

create table foo( pk integer)

create table bar
(
pk integer,
foo_pk integer references foo on delete cascade
)

Will this work?

___________________
Richard Rowell
rrowell at shreve dot net

2. US Computer/Info Tech

3. Referential Integrity & Cascade Updates/Deletes Triggers

4. Inserting a NULL using ADO

5. Cascading deletes with referential integrity catching me out!

6. HELP Wanted: Database Expert Needed in Seattle, WA

7. Referential integrity and cascading deletes.....

8. Cascading Delete Referential integrity problem

9. Cascading Deletes with Referential Integrity

10. referential integrity: cascading delete but not update?

11. Cascade Referential Integrity - SQLServer2000

12. Enforcing referential integrity using CASCADE constraint, MSDE