0

I am using the Clash Of Clans api to show all the members of the clan on a web page. But now I want to save all the donations, cups and received donations on a weekly base. So i can see in a very clear overview who are the most active members. But the thing is. I just don't know how to design the database. I was thinking to create a table every week that would look like this: StatsWeek[number]: (MemberTag, Donations, DonationsReceived, Cups). But then at some point i will have a large amount of tables. So I tought there has to be a more efficient way. But I can't think of a better way.. I am using a MySql Database

Luke Hol
  • 140
  • 8
  • 1
    Create one table with the week number as a field. – Nigel Ren Nov 29 '17 at 16:31
  • ...or something like that. You'll know when you hit on the right solution, because no further structural changes will be required to the database or its tables. – Strawberry Nov 29 '17 at 16:45

1 Answers1

0

Like mentioned in the comments, it's better to store everything in a single table... you can save weekly transactions(or daily, whatever interval you choose). Here is an example schema for you.

To find, for example, troops donated on any given week; you will have to subtract the previous weeks donations from that weeks donations.

Phillip Weber
  • 554
  • 3
  • 9