title: Database design: Calculating the Account Balance
body: <p>How do I design the database to calculate the account balance?</p>
  
  <p>1) Currently I calculate the account balance from the transaction table
  In my transaction table I have "description" and "amount" etc..</p>
  
  <p>I would then add up all "amount" values and that would work out the user's account balance.</p>
  
  <hr>
  
  <p>I showed this to my friend and he said that is not a good solution, when my database grows its going to slow down???? He said I should create separate table to store the calculated account balance. If did this, I will have to maintain two tables, and its risky, the account balance table could go out of sync.</p>
  
  <p>Any suggestion?</p>
  
  <p><strong>EDIT</strong>: OPTION 2: should I add an extra column to my transaction tables "Balance".
  now I do not need to go through many rows of data to perform my calculation.</p>
  
  <p>Example
  John buys $100 credit, he debt $60, he then adds $200 credit.</p>
  
  <p>Amount $100, Balance $100.</p>
  
  <p>Amount -$60, Balance $40.</p>
  
  <p>Amount $200, Balance $240.</p>