Subject Re: [firebird-support] Pre-testing delete for referential integrity issues
Author Nando Dessena
Myles,

M> I'm wondering if there is a 'best practice' for doing this. I have a
M> database full of contact records. Of these, many have related tables of
M> data that I can't delete the contact until those related records are
M> re-assigned to other parties. Consequently a Cascade delete rule won't
M> work here.

Not even on delete set null and on delete set default?
Could the orphaned records be parked so that they can be
reassigned right away? One good rule of user interface design that I
try to stick to as often as I can is that when the user is set to do
something you should try not to distract him with additional chores,
if at all possible.

M> But rather than giving the user the ability to 'try' to delete the
M> record and be told that they can't because of a violation of a
M> referential integrity rule, I'd like to be more pro-active with this and
M> only give them a delete option of the contact record has no related data
M> that would stop a delete from occuring.

I'm not sure you'd be doing them a favour, unless you also tell them
why. Nothing more frustrating in a UI than a disabled command without
hints about why it is disabled and how to fix it.

M> Is there is a good and fast way to determine if one of these records
M> could be deleted other than giving the user the ability to try and then
M> be told they can't? I'm basically trying to simplify their world a bit
M> by being proactive and telling them up-front that a record can or cannot
M> be deleted as it stands.

Looks like pretty much a waste of cycles to me, unless you could do it
at light speed without impacting what the user is actually doing,
which will not always be record deletion, *and* provide a hint. To
this end, IMHO Hans' approach would be the least wasteful among those
suggested, and you could modify it to also return some info about the
reason you can't delete.

Ciao
--
Nando Dessena
======================================================
I support Firebird, I am a Firebird Foundation member!
Join today at http://www.firebirdsql.org/ff/foundation
======================================================