-4

In my MySQL database, I'm trying way of creating a table to track daily views on 100 items. Each day would insert a new row for each item. So the table columns would look like this:

| ItemID | ItemName | Hits |

Is there a way to store daily hits for items?

halfer
  • 19,824
  • 17
  • 99
  • 186
Safin
  • 7
  • 6
  • 2
    Welcome to Stack Overflow! This question is a little short on information. Can you share what you have tried, and what problems you have run into? – Jay Blanchard Apr 15 '15 at 13:43
  • simply update hits columns on the basis of item id when the item is view. – Noman Apr 15 '15 at 13:43
  • This may be of use to you, as someone is doing the same thing: http://stackoverflow.com/questions/13659868/most-efficient-way-of-storing-daily-page-views-as-well-as-a-total-count – chronotrigga Apr 15 '15 at 13:43

1 Answers1

2

What you could do is have a table with a structure like:

| item_hits     |
|---------------|
| itemID | date |

Then your SQL query could look like

SELECT count(*) FROM item_hits WHERE date = '2015/04/15' and itemID = 7;

You wouldn't need to save the itemName in the table, because you should be able to get the itemName by joining it to your items table.

halfer
  • 19,824
  • 17
  • 99
  • 186
xJoshWalker
  • 457
  • 2
  • 12