1## Transaction Graph Operators
3Relational operators generate new relations and database context operators alter the relations referenced by relation variables. Finally, transaction operators alter the state of the database's transaction graph. This includes adding new transactions, branching, and changing the current database context to point at an arbitrary transaction in the past (time-travel).
5#### The Database Context
7Every database operation occurs within a database context. The database context is the state of the relation variables, constraints, and user-definable functions. While past transactions committed to the transaction graph are immutable, new transactions can be created from database contexts based on any transaction in the transaction graph.
9When a new database is created, a new transaction graph is created for it with one base transaction. The base transaction is special because it is the only transaction in the graph without a parent. At this point, the editable database context necessarily references the singular transaction. It can be considered a mutable copy of the database context stored by the first transaction.
11As the user interactively alters the database context such as by adding a new relation variable, the database context is no longer equal to that of the first transactions. This is called "database context divergence" because many of the same components exist in both the updated context and the context of the first transaction.
13: :commit
43Once committed, the transaction's database context becomes immutable. Internally, Project:M36 uniquely identifies each transaction with a UUID.
47Sometimes, the user determines that the changes in the mutable database context can be discarded and the context reset to be a copy of its parent's transaction. This is called a "rollback" because it rolls back to a previous known state. The equivalent in SQL is ROLLBACK.
50TutorialD (master/main): :rollback
53#### Show Transaction Graph
55In order to navigate the transaction graph, one must specify transaction UUIDs. Viewing the entirety of the transaction graph as a relation is a single command.
58TutorialD (master/main): :showgraph
59┌───────┬──────┬────────────────────────────────────┬───────┐
60│current│head │id │parents│
61├───────┼──────┼────────────────────────────────────┼───────┤
64The "current" attribute is a boolean value. If true, the transaction is the parent of the current database context. Commits will be children of this transaction.
66The "head attribute is a boolean value indicating whether or not the transaction is a "head" node of its graph. Head nodes are nodes which have no children.
68The "id" attribute is the UUID needed in order to navigate the graph.
70The "parents" attribute is a subrelation holding all parent transaction UUIDs for the given transaction.
75A new branch can be create from any point in the transaction. A branch associates a human-readable name with a set of transactions diverging from a parent transaction. After a branch, there are two heads to which one could commit.
78TutorialD (master/main): :branch testing_data_2005
79TutorialD (testing_data_2005):
82Note how the prompt refers to the new branch. This indicates that further commits from the mutable database context will now be added to the new branch.
86To switch the current mutable database context to refer to a different branch, jump to a different head. Committing to a head ensure that the branch growth continues linearly.
88Note that jumping to another head implies losing any changes in the current database context.
91TutorialD (testing_data_2005): :jumphead master
92TutorialD (master/main):
95Further commits will be added to the target branch.
97#### Jump to Transaction
99Instead of jumping to the head of a branch for the purpose of adding more commits, it can be also useful to jump to a specific transaction in the past for two possible reasons:
101* to examine the state of the database in the past; for example, for auditing purposes
102* to branch the database from a point in the past
104If one jumps to a non-head transaction, committing new transactions are no longer possible because the past transactions cannot be overwritten.
107TutorialD (master/main): :jump 11b601c9-f46b-42b0-a2ce-cf18ced31b7f
108TutorialD (11b601c9-f46b-42b0-a2ce-cf18ced31b7f):
111Note that the ```tutd``` prompt now indicates that the mutable database context now refers to a specific transaction by UUID.
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list