What is a NoSQL database?
It Is a newer family of databases. What does No-SQL stand for? It is a debatable question as there are multiple opinions. They call it ‘not SQL’ and some say ‘not only SQL’.
How come NoSQL databases are different from others,
- Most of the time they are Schema free, or nonrelational.
- Distributed (almost all)
- Horizontally scalable (can have the same instance running on many devices)
- Easy Replication
- Eventually Consistent
- Open-source (mostly)
There are different types of NoSQL databases,
- Key-value — Stores as Key-value pairs eg: Redis
- Document — Stores data as document (Json, Bson, XML) in maps or collections eg: MongoDB
- Column Family — Stores data in column families and rows that have many columns associated with them. Eg: Cassandra
- Graph — Store entitles and relationships between them and represent it in a graph. Eg: neo4j
Why we need NoSQL databases
Unlike in the good old days, are not bound to one single database. It is not the case that we have to select a particular database to use in each and every single application. At the present, we have the freedom and the privilege of selecting the database which is most suitable for our application. It is not the case that SQL databases are only best and we have to use them, for some applications SQL databases will be best, and for other applications, NoSQL may be best suitable based on the use case.
What are its strengths and Weaknesses?
Strengths / Benefits
- Handle large volumes of data at high speed with a scale-out architecture.
- Store unstructured, semi-structured, or structured data
- Enable easy updates to schemas and fields.
- Horizontally Scalable (scale-out across commodity servers)
- Joins are not required like in SQL databases
- Lack of Standardization — There is no standard that defines the rules and roles of NoSQL databases.
- Backup of databases — Backups are drawbacks in NoSQL databases.
C — Consistency: Every read receives the most recent writes.
A — Availability: Every request receives a response(may not be the most recent one)
P — Partition Tolerance: System will continue to operate despite a number of messages lost among network nodes.
However, you cannot achieve all 3 of these. You would be able to achieve only 2 of these anyway.