Question

I need to create a system to order some articles by they popularity, like a trend.

I have this table:

| Id | Title |  View |
|  1 |  aaa  |  232  |
|  2 |  bbb  |  132  |
|  3 |  ccc  |  629  |

This way I can easilly order by number of view, but if I want to show the populars articles in the last period (not definited) and not the articles that have a lot of views but they are not longer visit? Exist a technique? I have to track all visits?

Was it helpful?

Solution

You could have a daily_views/hourly_views table according to your needs with :

ID   startTime   endTime  number_of_views 

and INSERT/UPDATE that table every time you have a new view. That way you don't have to insert a record for each view and you can have queries for different time periods.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top