Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In an enterprise application, for business-critical data, it is always a requirement to keep “versions” of each entity. For example, in a customer relationship management (CRM) system, each time a customer record is inserted, updated, or deleted, the previous version should be kept in a history or auditing table to fulfill the firm’s auditing or other compliance requirements.
To accomplish this, there are two common options. The first one is to create database triggers that will clone the pre-update record into the history table before any update operations, and the second is to develop the logic in the data access layer (e.g., by using AOP). However, both options have their drawbacks. The trigger approach is tied to the database platform, while implementing the logic manually is quite clumsy and error prone.