samedi 27 juin 2015

How to structure data/models when I always want the last record for a group?

I have a set of users who will be entering some data once a week for their location - there will be 200+ locations. And I have an auditor who always wants to see the last set of entries (for all the locations) first. The auditor will be able to sort and filter to analyze the locations and decide if they action on the entries. The auditor may choose to review a specific locations history - but if so, only one location at a time.

The auditor will be reviewing the last record often and looking at history seldom.

I feel like I need to keep the last record for each location separate from the the history - so that requesting them is performant. And as new records are added, I insert the old into a history data store (or maybe it is best to insert new records into both tables at the same time - only updating the current data store and inserting in the history data store.

But I am concerned that this could cause unforeseen issues.

Or should I not worry about the performance of always have to query for the most current record by group? Is there a performant way to get this from your data store? ( in this case it is MS SQL Server )

Any guidance greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire