2) Understanding change
In part 1, we covered deleted data, and the fact that in an immutable database, data is never truly gone.
In this part, we’ll expand more on the idea of querying the timeline.
Let’s use a single record for this example.
Let’s pretend the first version is inserted on 2024-01-01
.
(Notice how we don’t have to create a database table explicitly, or tell our database about the columns - the database will learn the schema from the data we give it)
Let’s query this product:
A month later on 2024-02-01
, we decide to update the price of the product.
Let’s check the new price:
A month later on 2024-03-01
, with part costs still increasing, we increase the price again.
Let’s say we need to do an audit query, and we need to know
the price of every product as of 2024-01-15
.
Here you can see we have the correct historical price for 2024-01-15
, which is 340
Now let’s say our CFO wants to know how the prices have increased over Q1?
When did the bicycle price first exceed $350 ?
Yes, it was the price change of 2024-02-01
where the bicycle’s
price exceeded $350.
Conclusion
We’ve shown that it’s possible to view the past history of records in our database without creating any special views, audit tables or workarounds.
Let’s move ahead to part 3.