Answer the question
In order to leave comments, you need to log in
How to effectively store the history of attribute changes in the database?
There is a table in which there should be about 100 records. And for each record, it should be possible to view changes in a certain attribute (price) for the last hour, two, day, week ...
(For example: average price an hour ago ***, average for a week ***, for a month ** *)
Attribute values are measured approximately once per minute. How can this be done effectively? Is it possible to avoid creating additional columns with price values during the last measurements? In general, I hope for your support :)
Something like this:
Answer the question
In order to leave comments, you need to log in
Create a separate table in which to store the date, product id and price. And write there either in the application or triggers
better than radish.
store there lists of all changes per hour.
ps
just keep in mind that if the price for an hour was first 100r, then 110r, then 90r and then 200r, this does not mean that the average price per hour was 125r. the duration of such periods must also be taken into account.
maybe it was so that
1 minute - 100
2 minutes - 110
3 minutes - 90
4-60 minutes - 200
total average price is about 199
although in your case it may not be critical.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question