Skip to main content

FAQ: Multi-Version

What is a multi-version database?

While Uni-Version Systems (SQL and NoSQL) only keep track of the current state of the database, Multi-Version systems track every change that has occurred in the system. Data is never truly altered or removed, updated data is added to the data files. Therefore, data can be easily versioned.

How do I look at different versions?

There are two native implementations record-history and versioning in bSQL:

  1. Using the LIFETIME keyword in a query.
  2. Setting the transaction time using SET TRANSACTION.

These methods use the same historical data differently.

The first method reads directly from a blockchain's record history and allows users to generate historical datasets for identifying data patterns and anomalies.

The second method, allows you to run queries as if your transaction was being run at the specified time. After the query time is set, users can interact with a validated versions of previous states.

How do I use versioning to snapshot?

We can use SET TRANSACTION to simulate a snapshot. Transaction times are only valid for dates after the year 1678 and before 2262 because they have nanosecond granularity and stored as an INT64. Transaction times are session specific and different connections can simultaneously read from different versions.

SET TRANSACTION QUERY TIME "2021-02-26 00:07:10.000000000";

After running this command, all subsequent queries from the database will read from the state of the database at 2021-02-26 00:07:10.000000000.