title: Working out users points - update vs select
body: <p>I have users who earn points by taking parts in various activities on the website and then the user can spend these points on whatever they like, the way I have it set up the at the minute is I have a table -
  tbl_users_achievements and tbl_users_purchased_items</p>
  
  <p>I have these two tables to track what the users have done and what they have bought (Obviously!)</p>
  
  <p>But instead of having a column in my user tables called 'user_points', I have decided to display their points by doing a SELECT on all achievements and getting a sum of the points they have earnt, I am then doing another select on how many points they have spent.</p>
  
  <p>I thought it might of been better to have a column to store their points and when they buy something and win stuff I do an UPDATE on the column for that user, but that seemed like multiple areas I have to manage, I have to insert a new row for the transaction and then update their column where if I use a query to work out their total won - spent I only have to insert the row and do no update. But the problem is then comes to performance of running and doing a calculation with the query.</p>
  
  <p>So which solution would you go with and why?</p>
  
  <ol>
  <li>Have a column to store their points and do an update </li>
  <li>Use a query to work out the users points they can spend and have no column</li>
  </ol>