I want to ask your opinion in using MySQL triggers or transactions in a website.
Actually I have a history payment table with - UserId | OperationId | Comment | Credits | Sign (debit or credit). So each payment operation is inserted in this table.
However, it will be time consuming calculating each time the total credit amount of the user every time he do action. So I thought maybe is a good idea to keep the total credit amount for each user in a user profile table.
Here is the problem. How can I be sure that the total credit amount form the profile table will stay synchronized with the operations from payment history table ?
I thought using 2 methods:
- MySQL triggers or
- transactions coded in the source code
Which is more reliable? What if I have large database (over 100.000 users) ?
Do you have any suggestions to do this?
The BD MySQL engine is InnoDB.