J
J
jewxcelia2019-01-26 18:03:10
Database design
jewxcelia, 2019-01-26 18:03:10

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

2 answer(s)
V
Vitsliputsli, 2019-01-27
@Vitsliputsli

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.

E
Evgeny Gribkov, 2019-03-13
@jobgemws

look towards temporal tables: https://docs.microsoft.com/ru-ru/sql/relational-da...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question