What is the best way to store people's current balance in MySQL? I'm developing something like Neobux, so each user have a balance data in MySQL..
4 Answers
Use decimal(10,2)
. float
is susceptible to rounding errors, see here.
For further information, you can take a look at these pages:
I say store all of the transactions rather than just the current balance. That way you have history, and you can run different aggregates on it rather than just "final balance."

- 11,320
- 12
- 47
- 76
-
you would have to create a table to store the individual transactions, and link them back to the user table with a FK. – Mr Griever Dec 10 '10 at 17:56
For accounting in a relational database see Ruby on Rails REST design question - transfer money between accounts

- 1
- 1

- 7,568
- 1
- 35
- 48
If you would just store balance then add just a input in database but if you want to store all transactions you should get a new table with username as referrer to class all transactions automatically note that, if you aren't a great programmer it would be hard to make the type of website you want so please consider purchasing a ready one .

- 756
- 10
- 27