What Is blockchain?
A blockchain is essentially a database, just not in the traditional sense.
Blockchain is a decentralized database in which the constitutional elements are Blocks. These blocks are associated to the other blocks through cryptographic functions. The database is continuously growing as new data is added to the database.
Each block in a database, contains a Hash code which links it to the previous block, a time stamp of modification of the records stored in the block, and the records themselves.
As per Wikipedia: A blockchain serves as an open distributed ledger that can record transactions between two parties in a verifiable and permanent way.
The distributed mechanism of the blockchain means that a copy of the database is present in the network, on however many number of users are actively participating in the blockchain network. Each user maintains a full copy of the database, and whenever there is a change in the records of the blockchain, or a new block appears, the same data is replicated on every participating node in the system.
According to the Harvard Business Review Blockchain is a foundational technology, and thus ‘has the ability to create new foundations for our Financial and Social systems.’
The distributed nature of the blockchain means a very robust network which can effectively sustain itself without having a singular point of failure.
If we look at a traditional database, we know that it is situated in a central location, with an administrator or a set of rules in place governing what goes in and out. It has a backup somewhere which can be called upon in critical times. It might have a downtime for repairs or other organizational tasks to be performed upon. And, it is the point where a hacker will first look to attack if they want to alter, or change data, or steal valuable information.
Blockchain is essentially distributed. It does not have a single administrator. Each and every node connected to a blockchain network has the same level of write and read access to the database, and each and every node has a separate copy of the original database. As soon as a new entry is made to the chain, the entry is checked with all previous records and, if the entry is considered legitimate, is then added to the database which is then sent forth to all other nodes on the network. Once all the nodes agree that the data sent forth is valid (after checking it by themselves through their database history checks), a consensus is reached and the data is appended to a block and becomes part of the chain.
What is the difference between traditional databases and Blockchain?
The core difference between a standard Centralized Database and Blockchain, is the fact that a (public) blockchain can be accessed by anyone, can be shared across boundaries of trust. This is possible because there is no central administrator and each transaction contains within itself its own proof of validity and proof of authorization. A centralized database offers higher amounts of confidentiality, in that no one can check another user’s data.
A second difference is, as already discussed above, the robust nature of the blockchain network. The database is not located in a centralized location which means that, if a single node in the network fails, or many them fail, there is no loss of data, nor is there a downtime because of any ‘failure mechanism’. The chain continues to function as it is. The nodes connect in a peer to peer fashion, so a lot of communication links can fail before the entire system grinds to a halt. If a node goes back up online, it can always download the additional transaction data and be back up to date with the network. In a standard database, all this is being done by a central computer which contains the master database, with another backup hosted somewhere else.
How does the Blockchain prevent double spending?
The biggest challenge faced by the cryptocurrencies in their infancy, was double spend. What if an individual spends the same currency he had twice, sending it to two different parties. How is the blockchain ensuring that this does not happen without an administrator? Looking at bitcoin, at any given instance, the blockchain will have an idea of the history of the chain. Every coin has a history of usage. So, if a person A sends 1 Bitcoin to a Person B, the blockchain will check if person A had the coin to begin with, and looks at its history and how it ended up with A. The mining software, goes through the whole history of the blockchain to ensure that it was not spent earlier, otherwise it will not let the transaction go through. A more technical answer from stackexchange is as below:
You have two Unspent Transaction Outputs (“coins”) worth 0.03 BTC and 0.09 BTC. They were created as “first output of transaction X” and “third output of transaction Y” respectively. You want to send 0.10 BTC to Bob.
You cite these specific two UTXOs as inputs to your transaction Z. i.e. you order “I want to spend the first output of transaction X, and the third output of transaction Y. I’m converting them to first and second output of transaction Z. – Here are the signatures for X.first and Y.third.”.
X.first 0.03 BTC Z.first 0.10 BTC (spendable with Bob’s signature)
—- tx Z —>
Y.third 0.09 BTC Z.second 0.02 BTC (spendable by you)
In this example, you use up your two “coins”, to give one “coin” to Bob to pay 0.10 BTC, and get back the change as another new “coin” which goes to yourself. Your transaction Z spent X.firstand Y.third, and converted them to two new “coins” Z.first and Z.second.
Every node has worked through the whole blockchain. Every single transaction references one or more “coins” that get spent, and creates new “coins” as in the example.
While a node works through the blockchain, it keeps track of the “coins” that exist, and updates this database with every transaction that happens. The database is referred to as the Bitcoin network’s “Unspent Transaction Output Set”. So, when you’re up to date, the node has a list of every “coin” that is available for spending.
Back to the question
So, you sent 1 BTC to Bob one month ago. Now, you’re trying to use the same “coins”, X.first and Y.third a month later to send money to Carol. The nodes look at their “coin” database, and see that they are not in it. They can immediately say “Those coins have already been spent.”