Subject Re: Checksum of a Database
Author Adam
Hello,

Their request then is not an uncommon request, however it was
strangely put. In a nutshell, they are interested in who did what and
when.

Unfortunately, the checksum idea will not really help out. It will
tell them that SOMETHING has been changed, but that something may not
be anything of significance. It may simply be that a transaction was
started, and considering gbak would run inside a transaction the
checksums may not match even if it is identical. Without doing a data
comparison there is no simple way to see what has been changed, and
data comparisons bring their own problems.

I can see two possibilities.

The first is a program from upscene called LogManager that is
compatible with Firebird. You will need to decide for yourself if such
a product is overkill for your needs, but it is an option to consider.

Alternatively, most systems have only a couple of significant tables.
For example, even though our system has several hundred tables / views
/ stored procedures, you would only need to audit 5 or so tables.

You could simply create triggers on those tables to insert a record
into a log table, and then it is a trivial query to see what was done
to those tables since timestamp X. If you are using FB 1.5, you could
use the CURRENT_USER variable in the trigger to insert WHO made the
change, CURRENT_TIMESTAMP to insert WHEN the change was made, OLD.ID
to get the primary key of the modified / deleted record, NEW.ID to get
the primary key of the new record, and you may even include the entire
record that was changed if you really want. In fact, if you had such a
table, another relatively trivial operation would be to "undo" the
changes. The log table could be purged when the manager "accepted" the
changes made overnight.

Adam