My database requires some columns to be tracked, but not all. I've looked at a couple of designs to implement tracking such as(Ideas on database design for capturing audit trails).
However this seems highly wasteful and since I only really need to track a couple of critical columns I feel like this wouldn't be the optimal solution for me.
Now I thought of a way to tackle my situation, but I am not sure if I might be overlooking a design flaw with this approach.
User
----
ID PK INT
Username VARCHAR(MAX)
Employee
-----
ID PK INT
Name VARCHAR(MAX)
PensionScheme
-------------
ID PK INT
EmpID FK INT (References Employee)
IsActive BOOLEAN
ModifiedBy FK INT (References User)
EffectiveFrom DATETIME
The schema above is just a highly simplified example, but captures the essence.
Essentially an Employee can be on a pension scheme or not, the changes to this attribute have to tracked. When a change to that attribute needs to happen a new row is inserted with a timestamp.
If you want to figure out whether the employee is on a pension scheme or not you would have to find the row with the most recent timestamp.
The only flaw that I currently see is, that if an Employee is inserted that there is no matching row in the PensionScheme table. Though I am thinking of solving this with and INSERT trigger to add a default row.
I am really just looking for thoughts on this design. I am quite inexperienced with change tracking in databases.