I have an application that has a status table see Database best practices – Status for an example
I want to be able to show a history of the status changes. There are 2 ways I can see for implementing it using mvc3 and the entity model like this – http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application
I can always just have a StatusID property on whatever object needs to link to the status table e.g.
Job
ID
Name
StatusID
Status
ID
Status
Or, I could have a StatusHistory table and make the StatusID property a function that return a Status object e.g.
Job
ID
Name
Status
ID
Status
StatusHistory
ID
JobID
StatusID
Date
and on the Job model class (Job.cs) have a function called Status which return 1 Status Object by querying the StatusHistory table for the latest status object that relates to the Job.
Has anyone done anything similar to this?
you may have
StatusHistory
while Job contain current StatusID.
Job
this way you “cache” the Job’s latest Status instead of searching..
every time you need it.