Subject Re: Check constraint vs. ref. integrity
Author Alexander V.Nevsky <ded@hq.bereg.net>
--- In ib-support@yahoogroups.com, Bob Murdoch <ram5@e...> wrote:
> I'm setting up a new database, and wondering what the consensus is
on this
> situation:
>
> I have a couple of audit columns that are part of every table in the
> database. Those columns are simply Ins_User_ID, Ins_TS, Upd_User_ID
and
> Upd_TS, representing the user and timestamp of the insert, and the
most
> recent user and timestamp of an update.
>
> I could create a foreign key from each table to the Users table,
linking
> the Ins_User_ID and Upd_User_ID to the primary key of the Users
> table. Alternatively, I could add a check constraint (or manually
create
> BeforeUpdate/Insert triggers) to do the validation.

Bob, since it difficult to imagine users will be
added/dropped/modified to another ones in time of their work it is
safe to check it without references integrity - concurrency is near to
impossible and you need only one unique index on table Users not
low-selective one on every table on user_id.

Best regards, Alexander V.Nevsky.