Tony Toews <tt****@telusplanet.net> wrote in
news:ip********************************@4ax.com:
I also have an intense dislike of cascading deletes. <smile>
Especially when a user sees the system message they don't pay any
attention to the extra wording which goes along the lines of "(and
associated records in other tables)" And it can be way, way too
easy to start deleting records from too many tables. For example
you go to delete a customer and, whoops, cascade deletes just
removed all the customers invoice headers and invoice deletes.
Clearly that's an extreme example but is quite possible if someone
doesn't clearly understand what could go wrong.
Cascade delete on a customer table when there are invoice records is
clearly a schema design error, in my opinion. Invoices are something
that can't be deleted, as you must have the transactional record, so
the parents of the invoices themselves can't be deleted.
But, there are plenty of cases where cascade delete is fine -- when
the child records are not part of any body of important information
that is independent of their role as child of another data record.
For instance, a client's inventory application (and antiquarian
music dealer, where everything is a one-of-a-kind object, one record
per item, no inventory counts) has key words attached to the parent
record. They recently went through all the inventory items that were
numbered under their old inventory system and created new records
with new inventory numbers copied from the old record (the reason is
that in the old system the numbers were of the format ALS-1234 where
1234 could also be used for INS-1234; this eventually caused
problems for them, so they wanted to get rid of them). Then they
deleted the old records. The key words for the old records were
cascade deleted, as they should be, because they were only a join
table between the inventory table and the key word lookup table.
I'm working on an app right now that has an events table for
tracking things that happen over time, and a related sub events
table that breaks down particular variable values at the time of
each event. If the parent event is deleted, the sub events should be
cascade deleted.
Now, that's very handy during development. I'm not sure whether I'll
leave it for production use, especially since when the app is fully
installed, it will be getting its data from an automated import
routine rather than from data entry. But it's certainly a case that
if the parent records are deletable, the child records have no
function other than as a part of the parent.
--
David W. Fenton
http://www.bway.net/~dfenton
dfenton at bway dot net
http://www.bway.net/~dfassoc