| 92 | * T_KEY_VALUE_CHANGES |
| 93 | * It has five colums, unique DB id (autoincrement), foreign key to the db id of T_RESOURCES, foreign key to the DB id of T_KEYS and two foreign ids to T_REVISIONS, SET_REVISION_ID and CHANGE_REVISION_ID |
| 94 | * It represents a key value of a resource (the key and resource foreign id) at revision (SET_REVISION_ID). |
| 95 | * The CHANGE_REVISION_ID is the id of the next revision (null if the SET_REVISION_ID is the current revision of the key of the resource) |
| 96 | * The two revision ids represent history links. The idea is when changin a key, to find its current value row (CHANGE_REVISION_ID is null there for that key of that resource), |
| 97 | to modify the CHANGE_REVISION_ID to be the DB id of the new revision and to add a new row in the table for the same key and resource but with SET_REVISION_ID the DB id of the current revision and CHANGE_REVISION_ID - null. |
| 98 | * This way we can track history in the DB easely, get a value of a key of a resource at random revision, find previous revision, etc... |
| 99 | * The writes of a revision can be get from here (all the records that the DB id of the revision is SET_REVISION_ID). That helps the skip algorithm. |
| 100 | * T_KEY_VALUES |
| 101 | * Has two colums, a foreign key to the DB id of T_KEY_VALUE_CHANGES and a Clob column for persisted as string or binary data Immutables. |
| 102 | * This table contains the values for T_KEY_VALUE_CHANGES. |
| 103 | * T_REVISION_READS |
| 104 | * Has two colums, a foreign key to the DB id of T_REVISIONS and a VARCHAR column. |
| 105 | * This table represents the readed keys of a revision |
| 106 | * The varchar columns represent a full path of key (for example childre:Book.book.s2:children:Page A:title) |
| 107 | * The table can be represented as the T_KEY_VALUE_CHANGES table, but here we don't need links for the history, don't care of actual values, the meaning of the reads is simpler, so the structure of the table is simple. |
| 108 | * Reads are added rarely compared to writes, so the table is perfect for its purpose. |