0

I am designing a database and want to have audit information for all the changed value. I want to validate my approach -if there could be any down side to this, I already have gone through existing questions and have tried a few. This link summarizes almost all Database design for audit logging

Following is what I am thinking: A common table, say audit_info which have following columns

-->ID (generated)

-->TableName

-->Timestamp

-->beforeHashedValue -this will have all the info before changes hashed with key

-->afterHashedValue -this will have all the info After changes hashed with key

How will it work:

->Whenever a value change, capture entire row, encrypt it and write to audit table

->Write to audit table in async mode -By async mode I mean, before updating store a image of current data, If transaction successful, feed it to some thread which will do encryption and update table

->Use unique ID as foreign key in primary table, store it as comma separate string for multiple updates

->To retrieve values, Query on table and order by time stamp to get historical values

->decrypt each row to get the timeline data

Pros:

->I thinks this is pretty simple

->Would not impact primary tables

->No cluttering in each table, the main tables just need to store the foreign key to audit row (In current I have been storing audit info with each table and it has become a maintenance nightmare)

->For multiple audits, a comma separate list can be maintained which can used to fetch audit values

Some cons which I can think is:

->encryption and decryption can take time

->What about very large object? for example text, blobs? How encryption will behave?

->If audit is needed in real time, this can result in performance bottleneck!

->Need logic to map it back to domain model based table name

Given that:

My table do not have any BLOB, but at max text say 3k-4k words

There is no need of real time auditing,

Is there any major disadvantage with this approach?

Community
  • 1
  • 1
cpandey05
  • 1,241
  • 2
  • 17
  • 30
  • @ Neil McGuigan, I mean encrypt not hash (one way hash as md5), changed accordingly – cpandey05 Oct 27 '14 at 18:12
  • You mention using comma separated lists a couple of times. You might want to give this some more thought. Build a prototype. – Mike Sherrill 'Cat Recall' Oct 27 '14 at 22:22
  • I have mentioned comma for two places, one while encrypting the value and other to store as list of foreign key reference -second use is just to avoid the join table. I have build a small prototype, but that's it, am suspicious whether it would have downside in longer time frame! – cpandey05 Oct 28 '14 at 08:18

0 Answers0