The comparison between blockchain vs database can be a curious thing for developers but in general, it’s not so clear cut. Blockchains are types of databases, after all. As an example, Ethereum is powered by LevelDB while EOS is powered by MongoDB, which are very common databases for web developers. While a blockchain is a database, a database is not necessarily a blockchain. In this article, we will explain why and I’ll examine three major differences between a centralized database (usually relational database) and distributed databases (blockchain), and where we recommend either the use of a database or blockchain.
Blockchain vs database — three points for differentiation
1. Centralized vs Decentralized
In a nutshell, a database is a computer program that can store, process, and retrieve data. The data itself can range from numbers and texts to more complex structures.
Traditional databases are centralized (they physically run on one server and users can’t download them) and are highly secured because they store critical user and business data. As such, it makes sense that only a limited amount of entities can directly manage it — DevOps or system admins, for example, or interact with it — the backend of a web application.
Public blockchains, on the other hand, do not have a centralized structure where only a limited number of people manage the data or define the rules of an application.
Since blockchains are not owned by a publicly identified entity, the data itself is distributed across the whole network and any participant of the network can download it. This is possible due to the fact that the users of the network can’t directly modify the blockchain. They have to rely on the consensus algorithm that governs the blockchain. As a reminder, a consensus algorithm is an algorithm that defines under which conditions data can be added to the blockchain.
As an example, Bitcoin uses proof of work (original consensus algorithm in a Blockchain network) while EOS uses delegated proof of stake (real-time voting combined with a social system of reputation)
While the consensus targets how new data can be added to the blockchain and how it can be verified, decentralization describes the fact that the blockchain is not physically owned by one entity. Specifically, this means that the database is not running on a single server owned by a single entity. The blockchain is replicated across any computer that wants to download it.
2. Permissions vs Consensus
While blockchains rely on the concept of “consensus,” databases rely on permissions.
In a database management system, the administrator can define “users” that can communicate with the database. The term of users is broadly defined — it can be a person but also an application. For instance, the backend of a web application that checks if a person is trying to access certain information has the right to do so.
Traditional centralized databases have been designed to be managed by a limited number of users without the need for a consensus mechanism across different parties. Think of a database like a group of people where the administrator is the leader. He will have the right to determine which users are have authorization to access the database and modify it. This is one of the main features of the blockchain vs database debate.
A blockchain, on the other hand, does not rely on an administrator or on permissions. It relies on the consensus.
Among other things, a blockchain is typically made of the database layer, that stores information, and of the application/rules layer that governs how data can be added to the database. These rules are called consensus. However, all consensuses are not equally created. Some are more centralized proof of authority while others are more decentralized proof of work, proof of stake, etc…
Blockchains themselves can be public or private. In a nutshell, anyone can create blocks in public blockchains as long as they comply with the consensus algorithm. Private blockchains are usually more restrictive and are used in organisations and corporations that need to have a control over the blockchain. Usually both private and public chains can be downloaded and queried.
The main disadvantage is that everything is in the hands of the administrator. As such, he can delete or modify data or even the entire database. The trust factor is in that case very important.
While the blockchain is a very interesting technology that allows triple entry accounting and trustless applications, it comes with associated downsides. GDPR and data privacy does not work well with a publicly accessible blockchain. Moreover, the public key cryptography that blockchain uses relies on the user side security. That means that users need to protect and secure their public/ private key pair.
3. Append only — Blockchain
Finally, blockchains differ from traditional databases by the fact that blockchains are append-only. That means that new data does not replace old data, it gets appended to the database in such a way that there is a historical track record of all the changes. This is not the case in traditional relational databases where new data replaces the old one unless it has been specifically programmed to do otherwise.
This happens because blockchains organize data in blocks, defined by a timestamp and by the hash, a signature, of the previous block of data. This allows the data to be linked through time and provide a record of changes in the blockchain.
This functionality can be implemented in traditional databases (e.g. transaction history in banks) but are definitely not critical and are not supported by default. However, it is critical for blockchains that rely on a historical chain of transactions.
When it comes to the blockchain vs database debate, blockchains can be useful in ways that are totally different from traditional databases that rely on a centralized entity. Blockchains follow the idea that a system can be governed without a central entity such as a corporation or a country.
As such, those cases are quite few and very often some form of centralization is needed (financial regulations, compliance, GDPR etc.). That’s why it is essential to weigh for each and every application the pros and cons of using a decentralized or centralized system.