Answer the question
In order to leave comments, you need to log in
Which storage option is best?
There was a need to build a graph of changes in the rating of a post for a month and for all time. At the moment I came up with the following algorithm:
| post_id | avg_rating | date |
|---------|------------|------------|
| 1 | 5 | 10/12/2020 |
| 1 | 4 | 09/12/2020 |
| 2 | 3 | 10/12/2020 |
| 2 | 2 | 09/12/2020 |
| post_id | json |
|---------|----------------------------------------------------------------------------------------------|
| 1 | { { date: 10/12/2020, avg_rating: 5 } } |
| 2 | { { date: 10/12/2020, avg_rating: 5 }, { date: 09/12/2020, avg_rating: 4 } } |
[{ x: 10/12/2020, y: 5 }]
Answer the question
In order to leave comments, you need to log in
The 2nd one will load the base less and more the application - but in the application it’s all the same to calculate, in addition - there are options when the Chart itself draws on the received array on the front, so it’s easier to send it in its entirety and
problems will be sent when the range is not for all time, but for an interval - well, look at the volumes and optimization
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question