Hi, i am working on a site that allows members to make a small donations to a user’s (friend) marathon profile page… i have a ‘marathon_profile’ table in my database and i have a ‘donations’ table in my database.
MARATHON_PROFILE
- id
- user_id
- total_amount
- 10 more columns
DONATIONS
- id
- user_id
- marathon_id
- amount
- 5 more columns
I need to display the total amount raised on the marathon profile and i am trying to decide on how i should store / record the total amount raised and how i should query the total amount in order to display it:
01 - which table should i store the total amount of money received in
A - simply add / increment the $total_amount field in the ‘marathon_profile’ by the individual donation amount AND record each individual donation $amount in the ‘donations’ table
B - JUST record the individual amount in the ‘donations’ table and forget the idea of having a $total_amount and incrementing it each time
02 - how should i call for the total amount so that i can display it on the marathon profile page
A - just call for the $total_amount in the ‘marathon_profile’ table (this seems a lot less workload on the site)
B - run a query which will add up add the $amounts WHERE marathon_id = the marathon page (this seems a lot more work load on the site)
Thanks in advance for your help