I am currently working on a ASP.NET MVC 3 project in which I have to keep record of field changes with certain attributes. Example:
public class MyModel
{
public String PropertyOne { get; set; }
// Need to keep track of these properties
[RequiresSupervisorKey]
public String PropertyTwo { get; set; }
}
As soon as one of the fields is changed, it requires a supervisor to approve of these field changes.
Until the changes have been approved the record will be in a pending state, and I somehow need to keep the old record and the new record until such time!
What is the best practices regarding storing these records? Should I have 2 records in the table in the database or should i have a audit table that can store this data until it has been approved.
Thank you.
I’d save them in one table too. Use a combined key for identifying a unique row. Row ID with autoincretment id. and datetime as the second part of the combined key. When a 3rd row can store the state. This allows you versioning as well. If you select the field for display you select by id order by datetime desc where state is approved limit 1. Hope this helps 😉