# Query Processing in Blockchain Systems: Current State and Future Challenges
## 6 Overview of the State of the Art
### State of Technology  
The currently most popular blockchain system _Hyperledger Fabric_[101] manages a ledger that consists of a blockchain and a database that holds the current _world state_. The world state represents the latest state of a blockchain and is stored in an additional NoSQL database. Hyperledger Fabric uses _CouchDB_ (see [[https://couchdb.apache.org](https://couchdb.apache.org)]([https://couchdb.apache.org](https://couchdb.apache.org)); accessed on 15 December 2021) to this end. Despite the fact that a blockchain maintains a native data history, however, there are only limited interfaces to access this data history (e.g., through Fabric SDK (see [[https://hyperledger-fabric.readthedocs.io/en/release-2](https://hyperledger-fabric.readthedocs.io/en/release-2)]([https://hyperledger-fabric.readthedocs.io/en/release-2](https://hyperledger-fabric.readthedocs.io/en/release-2)), 2/fabric-sdks.html; accessed on 15 December 2021) or smart contracts). It is possible to execute comprehensive queries against the CouchDB, which manages the latest state. However, the result of a query is not cross-checked against the blockchain, so there is a possibility of reading tampered data. In such blockchain systems, there is no efficient technique to query the underlying data structure, i.e., the data history of the blockchain. A solution to overcome this limitation is therefore to duplicate the data of the blockchain (or even just the current state) into a separate database with support for a powerful query engine, while sacrificing the built-in technique of the blockchain to verify the integrity of data while computing the result of a query. If, thus, information must be directly extracted from the data history of the blockchain, expert knowledge and self-developed tools are required to extract this information. Furthermore, there are systems that have features from blockchains and databases. They are called hybrid systems and there are two alternative approaches. The first approach is to start with a blockchain system and then enhance it with database features. The second approach is to start with a database system and then enhance it with blockchain features. [PERSON] et al. [102] compare six of such hybrid systems and came to the following findings:  
**Blockchain Systems Enhanced with Database Features. ** These systems use blockchains as an integrity-protected data store and utilize a separate database layer on top of it. Within the network, storage operations are replicated (e.g., a block containing transactions) rather than individual transactions. Examples are:  
* _BlockchainDB_[103] provides a key-value database layer on top of a blockchain, which provides a simple get/put interface as well as an additional verify method for data verification. * _FalconDB_[104] provides a \"traditional\" database layer with temporal attributes on top of a blockchain. It relies on smart contracts for querying as there is an incentive model that each node remains honest. * _Veritas_[105] provides a verifiable database layer on top of a blockchain. **Database Systems Enhanced with Blockchain Features. ** These systems use ordinary database systems and utilize transaction-based replication. Within the network, each node manages its own database instance and executes globally ordered transactions (achieved through a consensus mechanism) on it. Examples are:  
* _BigchainDB_[106] provides a blockchain layer on top of a _MongoDB_ (see [[https://www.mongodb.com](https://www.mongodb.com)]([https://www.mongodb.com](https://www.mongodb.com)); accessed on 15 December 2021) database. As all blocks, transactions, and metadata are stored in it, the full query power of MongoDB can be used to query data. * _Blockchain Relational Database_[107] integrates a blockchain layer into a relational database management system, namely _PostgreSQL_ (see [[https://www.postgresql.org](https://www.postgresql.org)]([https://www.postgresql.org](https://www.postgresql.org)); accessed on 15 December 2021).