Tracking Points: Insert or Update?

I add a point system to my application, where for every action that the user takes (registration, voting, comment, etc.), they get award points. Since this is a fairly common feature, I wanted to get an idea of ​​how others implemented their points system.

More specifically, when tracking points, regardless of whether you make new inserts in the point table, and then simply do the SUM when you need the total, or if you update one record for each user. What key factors will affect a decision in one way over another, and what are the trade-offs?

Intuitively, since inserts are usually cheaper than updates, I would think that inserts are a way of assuming that the average number of points per user is not too large. However, I am not a db specialist, so I would like to get your thoughts.

+4
source share
1 answer

What key factors will affect a decision in one way over another, and what are the trade-offs?

Performance may not affect it. Probably the main passage will be whether you want to track how points were awarded. The user may want to return and view their actions and subsequent points. In this case, you will need to somehow track each award.

With this in mind, you should be inclined to some sort of point table with a row for each user / award.

0
source

All Articles