I came to conclusion to use model I described earlier. Just track every transaction in system and how it influence on system account (total money in system and fee part).
Database design (mysql) for game money account storage and update
Question
will try to describe problem.
The data:
I have a game in which players deposit and withdraw (won) real money. All gaming money stored in paypal account. For each game withdrawal and other operations I subtract some fee. All transactions and users accounts are stored in db(mysql)
The problem:
I need to keep actual data of total game money account. With part belongs to game(fees) and which to users.
The proposal for solution:
For each transaction create new row of game account changes. With this table we can get all history and account changes, fees
CREATE TABLE `SystemMoneyAccount` (
`accountId` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`changerId` int(11) DEFAULT NULL,
`totalMoney` decimal(11,2) DEFAULT NULL,
`totalFee` decimal(5,2) DEFAULT NULL,
`changeMoney` decimal(11,2) DEFAULT NULL,
`changeFee` decimal(11,2) DEFAULT NULL,
`changeDate` datetime DEFAULT NULL,
PRIMARY KEY (`accountId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
Looking forward for helping and any proposals. Thanks!
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow