What is the best way to create an access report?

0

I'm setting up a revenue site (PHP and Mysql) and would like to have a backend in the backend where I can find out which recipes each user sees the most, and then suggest other recipes based on those reports.

I thought about setting up a table in Mysql of type:

id|id_receita|id_usuario|data       |visualizacoes
1 |   34     |   10     |2018-04-10 |    3

Then with each recipe he sees, he adds a line, and if he sees the same recipe on the same day, he adds the views.

My question is: can this make the table very "heavy" when you have many recipes and many users? Is it the best way to set up a report?

Thank you!

    
asked by anonymous 12.04.2018 / 13:50

1 answer

1

Analyzing what you want ...

Suggest recipes for the user

There are several ways to do this:

1. Know which user accessed which recipe and how many times to save to the bank and select recipes from that data

You will have a field with the primary key of the table ( id ), two with the foreign keys of the user ( id_usuario ) and the recipe ( id_receita ), / p>

1.1. Have a quantity column and always add one more when the user sees a recipe.

This is an efficient way, but it is not more complete, since the only information stored will be how often the user accessed what revenue, even if they added a date field it will save only the last time a particular user accessed a particular recipe

1.2. Save each access on a different line and to know that amount use COUNT() grouping per user and revenue

This is a more costly method (more data to store), but this allows you to save more data that may be useful, for example, you can save the location where the recipe was accessed and from there suggest typical recipes local

2. You can also create a form where the user specifies their preferences

In this case I suggest the creation of several columns: lactose, sweet, salty, nutritious etc. and set to% with% of those with a given characteristic or% with% if you do not have

3. The least expensive form for the bank (less data to be saved, in this case none) is to suggest revenue from the current revenue, so if the user is seeing a revenue X, will be shown for it recipes with characteristics similar to X

IMPORTANT: Do not worry so much about performance, you do not need to fetch all the database data immediately, initially only search the revenue that the user is viewing and then, through AJAX, / p>

Evaluate what you want with your application, whether you really need to be so careful with a "heavy" bank and then choose what you think is the best

    
13.04.2018 / 02:50