History tables pros, cons and gotchas - using triggers, sproc or at application level.

Posted by Nathan W on Stack Overflow See other posts from Stack Overflow or by Nathan W
Published on 2009-08-09T03:31:11Z Indexed on 2010/06/01 10:33 UTC
Read the original article Hit count: 200

Filed under:
|
|
|

I am currently playing around with the idea of having history tables for some of my tables in my database. Basically I have the main table and a copy of that table with a modified date and an action column to store what action was preformed eg Update,Delete and Insert.

So far I can think of three different places that you can do the history table work.

  • Triggers on the main table for update, insert and delete. (Database)
  • Stored procedures. (Database)
  • Application layer. (Application)

My main question is, what are the pros, cons and gotchas of doing the work in each of these layers.

One advantage I can think of by using the triggers way is that integrity is always maintained no matter what program is implmentated on top of the database.

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about database