title: get top n most viewed photos in a given period of time
body: <p>I want to display 3 most viewed photos for 7 days. Let's say that I have 4 images, A, B, C and D.</p>
  
  <p>Number of total views:</p>
  
  <pre><code>A - 300
  B - 305
  C - 310
  D - 400
  </code></pre>
  
  <p>Number of views in the last 7 days from now:</p>
  
  <pre><code>A - 100
  B - 90
  C - 95
  D - 45
  </code></pre>
  
  <p>So the 3 most viewed photos for 7 days are A, B and C.</p>
  
  <p>But after 10 minutes it changed! Let's say that someone visited photo D a lot of times, and the table looks like this:</p>
  
  <pre><code>A - 95 (yeah, it can decrease)
  B - 92
  C - 98
  D - 105
  </code></pre>
  
  <p>Now, the 3 most viewed photos for 7 days are B, C and D.</p>
  
  <p>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.</p>