I want to display 3 most viewed photos for 7 days. Let's say that I have 4 images, A, B, C and D.
Number of total views:
A - 300
B - 305
C - 310
D - 400
Number of views in the last 7 days from now:
A - 100
B - 90
C - 95
D - 45
So the 3 most viewed photos for 7 days are A, B and C.
But after 10 minutes it changed! Let's say that someone visited photo D a lot of times, and the table looks like this:
A - 95 (yeah, it can decrease)
B - 92
C - 98
D - 105
Now, the 3 most viewed photos for 7 days are B, C and D.
The question is: how to structure the database? I only have information about a total number of views and the date when the photo was published.