I have a complex web site that handles online games with real money. I use a double-entry database design for my transactions, a simple example is as follows:
John deposits $5 John receives 5000 credits John uses those 5000 credits to play a game.
The transaction in the database looks as follows:
trans_id | account_id | trans_type | date | amount |
-----------------------------------------------------
1 | John(PayPal)| Debit | date | -5.00 |
2 | System | Credit | date | 5.00 |
3 | SystemGame | Debit | date | -5000 |
4 | JohnGame | Credit | date | 5000 |
I wrote a stored procedure with a transaction in it that inserts transactions 1 and 2, the Debit from John's PayPal account, and the Credit to our System account.
My question is, should I also include the other transactions where John has money transferred from our SystemGame account to his Game account? Or should I have a stored procedure for each group of transactions? All 4 transactions occur simultaneously, John is credited immediately after depositing the $5.
Also, should I separate the transaction tables for game credits from the real money transaction table?