I want to implement approve reject workflow using relational database. Currently i am using MS-SQL database along with NHibernate.
Example:
Lets say i have below entry in database
ID Name Location FromDate ToDate ApprovalStatus
1 ABCD London 1-Jan 31-Dec approved
now the logged in user can change the entry using front end... which will go for approval
ID Name Location FromDate ToDate ApprovalStatus
1 ABCD London 1-Jan 30-Jun edited
If the authority approves the editing then the edits should stay, but if the changes are rejected the i want to revert back the old entry.
There are few ways to implement this, but all of them need lot of boilerplate code for each table and i have around 20-30 such entities which follow the approval process as shown above. The options I can think of are
1.create another table which is replica of original table to maintain the edited entries/ approval workflow. just .
pros: easy to manage, just replace replace the original entry in case of approval, delete in case of reject
cons: too many duplicate tables + similar number of duplicate domain classes
OR
2.use same table, but create duplicate row, which keep track of the parent row and does appropriate changes on approval/rejection.
pros: reduces unnecessary tables & domain classes
cons: really complex to manage
I think the scenario is pretty common and there must be some material/ framework/ architecture addressing this issue. though i am not able to find out anything relevant even after much googling...
please help...