Subject Detect FK usage
Author Chad Z. Hower aka Kudzu
There is probably no easy way to do this...

I have a table that has many inbound FKs on it. I only want entries in this
table to be editable or deletable if they are not in use yet by any other
tables. For delete its easy, I try to delete and if its in use it fails.
Great.

But for edit - how can I determine easily if its already in use and then
decide to allow it to be updated or not? I don't want to hard code checks
against every table as this will lead to bugs in the application code in the
future as more tables are added.

The only "interesting" idea I've had is to try to delete it and if it does
not fail, then rollback and then edit... But this is a really bad idea that
I don't like. Im not even sure yet when the error would occur, on delete or
on commit (which would be too late).

I could also try changing its PK to a temp value to check for usage, but I
don't like this idea either.