Practicing web development by making a social network. Users can earn points for performing certain activities, so I have a PointHistory table for each User where point transactions are stored. To calculate the point balance, it makes more sense to have a dedicated PointBalance table that gets updated every time there is a change in a user's point balance, right?
Example scenario: userA earns 10 points -userA's PointHistory table is updated, transaction1 is recorded as +10 -userA's PointBalance table is updated to add 10 to the pointTotal
The alternative would be to have an algorithm that runs through the PointHistory table and calculates the point balance every time a point transaction occurs.
The dedicated table sounds like it would take fewer resources- or am I missing something?