Blockchain dataset vs traditional databases

Traditional databases:

  1. Have a centralized network.
  2. It can create, read, update and delete.
  3. They are mutable (data can be updated after being added).
  4. Authorization is centralized and transparency is low.

Blockchains:

  1. Distributed (control given to nodes, need consensus).
  2. It can read, append and validate (accurate historical record and faster read and write).
  3. They are immutable (permanent historical record but high storage space).
  4. Authorization is distributed (more secured).
  5. Transparency is generally high (everyone has access but no permission control).

Do I need a blockchain. Some useful questions to be responded.

  1. Do I need a database?
  2. Does it require share write access (users will need access to add or write to the database)?
  3. Will I need to create the trust between users?
  4. Can I operate without trusted 3rd parties?
  5. Can I operate without control over permissions?

Blockchain types

Who is allowed to participate in the network, execute the consensus protocol and maintain the shared ledger?

Public

Everything is open, everyone has access and can verified.

Private

The functionality of a blockchain but with access control.

Hybrid

Some transactions are public and others are private.

Private and Hybrid are a recentralization of the information.

Questions before choosing one:

  1. Will transactions be public? -> if yes, public
  2. Will other companies need access to your data? -> if no, private
  3. Should some information be public while other information is restricted? -> if yes, Hybrid

Blockchain network

Blockchain uses a peer to peer (P2P) network vs Client-Server used by traditional applications.

Client-Server brakes up tasks between providers and requesters. The server is a centralized resource that contains the information users want to access. The client make requests. Web servers or file servers are exemples. Data is controlled in centralized servers. It gives fully control over permissions. Overall considered more stable because a central owner can add or remove computation and storage to meet the demands of the client. A failover system is built in into the this model.

P2P is a network of computers that share access to files with each other. So every node is the server and the client. Is generally considered less stable, especially when is getting started. The network itself is not contributing to the security but the cryptography.

Block structure

  • Block Header: Metadata about the block like the hash value.

  • Block Transactions: all the block transactions information. You can explore block content using sites like blockexplorer.com The first transaction in the list (the oldest) is called “Coinbase”. The interface renders the data in a pretty way, but as programmers will use data programmatically, in json format for instance.

Exploring a block of bitcoin data.

  • Blockexplorer.js is a library allowing us to get a block by hash (or raw block, get the block hash by height and many other things.

An example of code getting a block from an index:

const be = require('blockexplorer');

function getBlock(index) {
    let hash = be.blockIndex(index);
    
    hash.then(function(value){
        return JSON.parse(value).blockHash;
    }).then(function(value){
        return be.block(value);
    }).then(function(block){
        console.log(JSON.parse(block))
    });
}