In our application a user can edit/delete certain items on a wall - which are viewable by others on the same team. Now what's the best design approach to solving this issue of history maintenance?
Here are some design ideas that I have in mind but don't know which is a good/better approach to go with:
- Create a duplicate schema (or a duplicate table per table) for the current tables. Call a trigger before update for each of them. But I only want it to fire only if the 'text' changes and not other attributes. Don't even know how to go about this
- Create a 'history table' - i.e., a global table where an attribute is used to isolate which table/item that history record is for.
- Have an asynchronous component that is responsible for updating a special table(s) with the corresponding update - more like a hashmap kind of storage. But I don't know how could this be done with Java/Mysql or is it even worth the effort. Creating asynchronous components are non-trivial
The first of the two approaches would use triggers. But then I don't want the trigger to do anything if just the timestamp or other configuration related fields have gotten updated for a record. Assuming about 50-100 concurrent users, would triggers be a good option? (or is it better to go with a stored procedure approach to do this...not sure).
Intention of such a design: We wish to basically perform some data analysis on the changes/deletions etc., We also wish to check for 'new items added' but that's easy from the timestamp and doesn't affect the history aspect. I'll have to design for each of the above points differently and wanted to know how best to approach the problem - i.e., best way to handle something like that in enterprise applications. I wanted it to run it by the community to get some suggestions/directions/pro-cons for some of the approaches. New/other better approaches are more than welcome!
I've gone throug some posts on SO and they seem to be DB specific but don't necessarily answer my question directly - they tell me the how for the first option but not necessarily whether it is a good way to go about it: Data history tracking best practice and How to track data changes in a database table
PS: I'm not using any ORM, but rather going with Spring JDBC. It was decided an ORM was not worth it...