views:

11

answers:

1

For my next app, users will likely have a number of 'points' which changes constantly. For example, a user might accrue a number of points for performing a task, have points taken away, or have points donated to them.

I'm wondering whether to store that value and update it constantly in addition to a 'history' table (which would contain the increments and decrements in points per user), or to calculate a user's current number of points when needed in addition to this history table.

Obviously having this value stored presents redundancy, but would perhaps be preferable to calculating points from multiple rows in the history table hundreds of times.

A: 

I would store the actual points value and perform updates when needed. You could keep a history of changes by implementing a trigger.

Barry