Answer the question
In order to leave comments, you need to log in
How to create a table to store the history of changes?
The table has a column with a price, the price changes over time. It is necessary to make a table that would store the history of price changes. That is, in the table with history there should be columns with the date of change and the price for which they changed.
Answer the question
In order to leave comments, you need to log in
Probably the most optimal way is to make a field with time changes. If it is filled, then this is history, if not filled, then the current state. In order not to complicate queries, create triggers for selection, update/delete, that perform operations with this field, but for the user it seems to be non-existent, except for specific questions about the history. And, of course, set up table partitioning so that the current and history are physically stored separately.
look towards temporal tables: https://docs.microsoft.com/ru-ru/sql/relational-da...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question