In a centralized database system, it is easy to control access and consistency where everyone is using the same database. Additionally, in a centralized database, there is a central trusted authority to control access because there is only one database, and all participants or clients use the same set of data. It should be trusted by all the participants or clients that the owner of the database never manipulates the historical data for any reason and database is correct.
What if, the participants cannot trust the centralized database owner and need high security and trust for their data as well as none of the companies want to take ownership and responsibility of the centralized database? In this case, we need distributed database.
The distributed database uses multiple copies of a database and there is always synchronization if anything changes in a single copy of the database.
In a distributed database, each participant can have their own copy of the database. The main advantage of distributed database is that it is easy to control and access as well as you can integrate your other systems and processes into your own copy of the database easily. However, as already explained there is always synchronization of changes to each database which is mandatory.
What is Blockchain?
Blockchain is a technology for record-keeping and contract enforcement. Simply blockchain is a software code and data. It uses cryptography to make it extremely difficult to modify the previous history. Blockchain technology is referred to as a secure, shared, and distributed ledger which is just like an accounting ledger containing a history of transactions in multiple locations.
Blockchain uses cryptography to digitally sign and secure the transaction. Cryptography in blockchain secures the transaction.
- Blockchain is a decentralized solution that uses a decentralized database.
- It uses consensus rules to make sure data is consistent across nodes.
- It uses cryptography which ensures participants trust the data.
In a blockchain, a cluster of data is kept in a block that has a unique identifier and a history. Blocks keep transaction information for example date, time, amount, and digital signature of the user. Blockchain is a connection of a network of devices such as computers, mobiles, etc. One device is considered as one node. Blockchain uses a peer-to-peer network to connect the nodes. In blockchain, different nodes such as computers, and mobile devices communicate with each other through peer-to-peer network protocol and share information.
When to use Blockchain?
There are many cases where the centralized database is a better option. However, in the following scenario, we can use blockchain.
- When we need to support several partners and companies.
- To avoid central authority: When participants do not trust a central authority
- To ensure consistency in a distributed database.
- To ensure trust and integrity between the participants, maintaining the order of transactions and transaction privacy is needed for partners and companies.
Where to use Blockchain?
- International trade and commodities
- Supply chain
- Energy and identity management
- Internet of Things
- Government sector/projects
- Healthcare and medicine
- Gaming, NFTs, Metaverse, Defi, and crypto exchanges.
The key components of Blockchain
A Consensus algorithm, Encryption, Hashing, Peer to Peer network, and Distributed database are key components of a blockchain.
- A block is the smallest unit of data storage. A blockchain is a chain of blocks.
- Each block consists cryptographic hash of the earlier block, a timestamp, and transaction data.
- Transaction data existence is proved by the timestamp. As each block contains the previous block’s information, they form a chain where each additional block reinforces the one before it.
- So blockchain is resistant to modification as each block keeps the information of the previous block, the data in any block cannot be altered retroactively without modifying all subsequent blocks. This is why blockchain is immutable and no one can modify it once data is saved on the blockchain.
Hashes ensure data is consistence and not altered. It is the method of cryptography that converts any form of data into unique text in string form. Whatever the data type or data size, any data can be hashed.
- The computer or device where the blockchain runs is called as a node.
- Each node in a blockchain keeps an exact copy of the database and runs the same blockchain code.
- Blockchain code uses the Consensus rule and the nodes where the code runs becomes the decision maker on the consensus algorithm.
- Nodes use consensus protocols to agree on the blockchain content.
- In Blockchains there is a general agreement on the protocol by each participant. Based on this agreement blockchains are created. This agreement is known as consensus rules/protocol on a blockchain.
- Simply, the meaning of the word consensus is “consent”, which means even if parties or participants disagree or are denied there is an overall agreement/consent to go forward in order to resolve the disputes in Blockchain.
- Nodes use consensus protocols to agree on the blockchain content.
- Every node must agree to the network-verified transactions to be permanently incorporated into the blockchain network.
- The main purpose of the consensus rules is to ensure that a single chain is used and followed by every participant (node) on the network without the need for a trusted central authority.
- If there is major disagreement ever occurs on the consensus protocol this may eventually result in a hard fork because of which it splits the single chain into two separate chains.
- Each node keeps the exact copy of data in the blockchain.
- Encryption is the most critical tool used in cryptography.
- It is a way to make messages or data unreadable to unintended users and can decrypt and make it readable only for the sender and recipient of the transaction.
- Encryption is a way to make data and messages unreadable and blockchain uses this to secure the information from untended users.
Distributed Ledger Technology (DLT)
- Distributed ledger technology is a technology to keep a record of the ledger of any transaction in a decentralized manner in different locations.
- Simply in DLT, the transactions and it’s details are recorded in multiple places at the same time.
- It’s a database shared, synchronized, and replicated by multiple participants across a large network. Each participant (node) synchronizes with the latest update of data and keeps one copy of the database with it.
Private/Public Keys and Digital Signature
- In a blockchain, asymmetric cryptography is used to generate a key pair. This key pair contains the private key and public key.
- The public key is used to create an address that is used to send/receive the transaction and you can share this address with others to send the funds.
- The private key is used to sign the transaction. The digital signature provides verification and authentication of ownership of the user on the blockchain.
- Using this cryptographic digital signature user can sign the transaction verifying that he/she is the owner of that asset.
How does Data get stored and updated in Blockchain?
Blockchain is a connected network of devices. When anyone runs blockchain software and tries to connect with the blockchain network for the first time then the blockchain database will be downloaded and one copy of the database remains in the machine. After that, it starts synchronizing with all network nodes.
Let’s assume there are 10 devices connected using peer-to-peer network protocol in the blockchain network named N1, N2, N3 to N10. Each node has its own copy of the blockchain database on it. Suppose N5 creates a new block and updates data in the block on the local copy of it’s own then other nodes must agree that the transaction creation is valid, or data update by the node N5 is valid then this update will be reflected to all other node’s databases. If other nodes disagree on the update of data, then the update will be discarded and there won’t be any changes in the whole blockchain database.
- N5 creates a transaction and updates data in it’s copy of the database.
- Then, other connected nodes must agree that the update made by N5 is valid.
- After that, the changes in the database will be updated to all nodes’ databases and the whole blockchain data will be updated.
- If there is major disagreement on the changes made by N5 then the changes will be discarded. The database will be the same as it was earlier.