Today, it is not hard to believe that, Millions of terabytes of data is created every single day, With this exponential growth of data industry it was time for the industry to move towards something which is better than SQL to handle tons of data, You got it right NoSQL.

What is NoSQL?
NoSQL or NOT ONLY SQL as the term suggests is not only limited to SQL but has much more under the hood, which will be disclosed as the article proceeds, Traits which every NoSQL database will have: Eventual Consistency, Map Reduce and Sharding.
Eventual Consistency:
Think of it as a car with low acceleration but high speed of 200 kph, we know this car in the long run will achieve this speed, Similarly with the NoSQL databases one should know that these will become consistent in the long run and may or may not be consistent at a given point of time.
NOTE: Consistency Means when data is updated it should simultaneously reflect in the database such that every operation after the update operation processes on updated data and not on the old one. This is does not hold true with NoSQL databases.
Map Reduce:
Map reduce is used when database is in clustered environment, It takes a query splits into multiple parts and processes these parts on different nodes in parallel, Then uses reduce set to merge the result of every part of the query. Thus map reduce helps in fast query processing.
Sharding:
Sharding is used to partition the data and store it on different nodes in a clustered environment. This is useful when the user set of a data is huge, data required by the user can be kept in node closer to him resulting in efficient performance of database lookups.
Now, It is easy to make out from these properties that NoSQL databases are designed to work on clustered environment.
Now the question arises, why we need a database to work on clustered environment?
Think of scenario where your app has 100 thousands of users will it be enough for you to have single instance of database responding to there queries, No right? With more number of databases instances response time increases.
Ok, Got It ! NoSQL works best with clustered environment but why not SQL?
It is because of ACID properties of transactions in SQL, which hinders the performance in clustered environment.
What are the types of NoSQL databases?
Key/Value Stores:
These types of NoSQL databases store data in the form of key value pairs, Just like dictionary in python. eg: Redis
Document Stores:
These types of NoSQL databases store data in the form of key/value pairs but here value can be anything another document or any attachment like a pdf or any other file. eg: MongoDB
NOTE: These Databases use JSON as storage format.
Wide-Column Stores:
These types of databases stores data in the form of tabular columns where each row contains key/value pairs where key is the name of column but each key/value pairs or groups of it are categorized under a super column.
eg: Name(super column): Last_Name(column:key), First_Name(column:key)
eg: Hbase
Graph Databases:
These types of databases stores data in the form nodes and attributes.
eg: My_Name(node): My_Friend(attribute:value):Value(points to another node) and the graph continues.
This type of database if well suited for representing social graph.
eg: Neo4j
Important Note:
Records (Rows) in any flavor of NoSQL databases can differ in data attributes ie. every can differ from another row in the database unlike RDBMS where each row must contain data as specified at the definition of the table.
Advantages Of NoSQl over SQL:
Formal Schema:
Most of the data being generated today is not structured and it is difficult to assume the structure of data beforehand, With the RDBMS or SQL one has to define the structure of data before storing it, This conflict is resolved by NoSQL technology in which there is no restriction over the schema of data as it can change from every row to row.
eg: Data generated by Heat Sensors is completely unstructured and is difficult to store with RDBMS but thanks to NoSQL, one can store it easily without worrying about the schema of data which changes from time to time.
NOTE: Data being generated today (Big data) is completely unstructured (now we know), is easy to store using NoSQL than SQL.
Clustered Approach:
From the start of this article we have been talking about how NoSQL works well in clustered environment and SQL doesn’t because of it’s ACID properties is another big advantage of NoSQL because processing BIG DATA today is essential part of any organisation and is difficult to achieve when there is only single instance of database running. Thus NoSQL has advantage over SQL when it comes to BIG DATA.
Storage VS Normalization:
NoSQL stores data as flattened collection thus increases the response time of lookups but SQL normalizes data and stores data in different tables for storage optimization, since NoSQL is for Big Data applications it is more for fast lookups than decreasing the storage costs.
Why is NoSQL best suited for Big Data than SQL?
Let us discuss about CAP theorem where ‘C’ stands for Consistency, ‘A’ stands for Availability and ‘P’ stands for Partition Tolerance. According to CAP’s theorem only two out of three can be achieved by any database technology, NoSQL focuses on ‘A’ and ‘P’ whereas SQL focuses on ‘C’ and ‘P’, Since big data is all about availability of data at all times for processing and analytics, NoSQL makes sure for this to be true by putting any update query in a buffer and Read queries are prioritized thus we say that NoSQL databases becomes consistent in long run thus are eventually consistent, Whereas SQL databases blocks every query until the update query is completed thus makes sure for the database to be consistent at all times.
Where to use SQL and not NoSQL?
SQL databases are well suited when your application is required to be consistent. eg: Banking Applications, one can pay only when his/her account has that amount of balance.
Another scenario where SQL databases are well suited, when structure of database is known beforehand and is not expected to change more often.
eg: Singup schema, one can know beforehand what all information is required for the user to signup for the application.
NOTE: An application can use both SQL and NoSQL, where some parts can be on SQL and other on NoSQL for better performance.
✉️ Subscribe to CodeBurst’s once-weekly Email Blast, 🐦 Follow CodeBurst on Twitter, view 🗺️ The 2018 Web Developer Roadmap, and 🕸️ Learn Full Stack Web Development.