Xooa Ledger Database (XLDB) is comprised of two databases: A mutable document datastore called the State Database, or World State, and an immutable database called the Transaction Database, or simply the Ledger. The Ledger is an append-only, and is cryptographically protected against modifications using blockchain technology.
When a key-value pair is created or updated, the World State is modified using a transaction. The transaction is appended to the ledger. All changes to key-value pairs (including deletions) are recorded in the ledger and can be queried via the History endpoint.
The key uniquely identifies the key-value pair within the World State database. The most appropriate method for constructing keys varies by use case: For example, if you are only interested in the append-only nature of the XLDB, and not in state db, or rich query, it doesn’t matter what you use as a key, and you may find it convenient to use the same key for all transactions. You can use the History endpoint to fetch all transactions and their payload.
If you wish to search based on the content of each transaction (the payload), you will then need a unique key (such as uuid) for each transaction, because such a search can run only against the state database (see Query endpoint for more details)
XLDB State Database may be used to store different object types (such as cars and people), typically using different JSON document schemas. If this is your use case, it makes sense to combine the object type and the unique object identifier into a single key. Another best practice with multiple object types is also to denote the object type within the JSON representation of the value. It will facilitate query filtering by object types.
It is recommended that values are formatted as JSON objects to effectively utilize the rich query capabilities of the query endpoint.
XLDB enriches values with metadata fields such as the identity of the token holder that created or modified the key, and the last-modified date. These metadata fields may be used to filter a query using the Query endpoint.
More details on the XLDB APIs can be read and tried here.
More details about World State, transactions and other app related features can be read here.
Do you like video tutorials instead? Check out the video tutorial for XLDB here.