NoSQL does not mean “No SQL” it means “not only SQL”. It is not an alternative to SQL databases rather it has different database design approach other than relational database.
NoSQL databases can be classified into 4 basic types:
- Key-Value Store: Schema-less format with a big hash table of key and values. (Example: Azure Tables, RIAK, Amazon Dynamo)
- Document based Store: Document oriented or semi structured data. (Example: Mongo Db, Raven Db, Azure Document Db)
- Column based Store: Stores data in form of columns instead of in a row. (Example: Cassandra, HBase)
- Graph based Store: A network database that uses edges and nodes to represent and store data. (Example- Neo4J)
Top 5 reasons when you should think of using NoSQL database:
- Nature of data:
The first thing you should think about is how is your data. Nature of your data ultimately dictates the choice of database.
If it’s simple tabular structure and requires strict compliance with regards to schema, data integrity and consistency then relational databases are adequate; but if the data is volatile like changing object models and data structure formats which needs flexibility or if it is having multiple levels of nesting or hierarchies then the complete data model tends to become very complex and cannot fit in row column structure. In such cases one should choose NoSQL database.
- Horizontal Scaling
When it comes to scaling, enterprises tend to scale horizontally which is cost effective with better fault tolerance. Scaling relational databases, Database Administrators mainly rely on scaling vertically or buying bigger, expensive multiple servers rather than distributing the load on multiple hosts. Horizontal scaling involves distributing data across multiple nodes which make data maintenance chaotic.
Architectures of NoSQL databases are designed with the intent to support transparent and horizontal scaling involving distribution of data across multiple low cost hardware nodes. NoSQL servers can be added or removed from the database layer without causing application downtime. These are built considering ease of maintenance while scaling in or out.
- Reduction in Cost
Scaling of relational databases involve high configuration and expensive servers as well maintenance of these involves assistance of expensive and highly trained database administrators overall increasing the cost.
NoSQL databases typically use clusters of low commodity hardware to manage high volume, velocity and variety of data. Features like automatic repair, simple data models, easier data distribution makes administration and tuning lesser. Due to these factors cost of storing and processing per GB worth data becomes cheaper.
- No Fixed Schema
Today we have huge variety of data like structured, semi-structured and unstructured data. Due to semi-structured and unstructured data, flexibility and fast changes are needed in data models and schema.
Schema management is a big headache in relational databases, even minor changes in schema are needed to be handled carefully and may need downtime as well.
Database schema need not be defined while inserting data in NoSQL databases. The model or schema can be changed anytime without application downtime. This provides huge flexibility in application and business logic.
- In built caching facility
Caching in relational databases needs to be done using separate infrastructure.
In order to increase performance, NoSQL databases caching techniques cache data in system memory itself without needing to have separate infrastructure.