I am developing an MMOG (not specifically RPG), in this MMOG there are several mini games which the user can play. Users can earn gold from this each of this mini game (depending on their score).
User also can spend their hard-earned gold to buy in-game items (accessories, upgrades, etc).
I am now still confused on how should i design the database which could keep track every transaction in an efficient manner.
What i have in mind at the moment is
- I have several tables (Users, Game, Log, Session, etc)
- I am thinking of creating another table called savings and spending. Inside it should have column like id, user_id(FK), amount (both for saving and spending respectively) and for saving table there could be game_id (to indicate how much gold a user get from a particular game) while for spending there could be item_id (to indicate how much gold a user spend on a particular item).
This way, i think it would be easy to calculate the current amount of gold a player have SUM(saving) - SUM(spending) from the begining of time.
I had a suggestion to put a column called 'gold' or something similar in Users table and just updates its value everytime a user spend or gather gold. But, i feel that it just too simple to be true.
Can anyone guide me to the right direction?
Cheers