LifeinAsia - 1:39 am on Dec 4, 2012 (gmt 0)
A table with
should give you what you need.
With an index on UserID, a query should give return the current balance for a given within a few seconds, even with millions of users generating thousands of transactions each.
You could also have an additional table with
that gets updated each time a transaction is made.
In other words, the first table would be a log of all the entries, and the second would be a running total for each user.