What Is NoSQL
What Is NoSQL
What Is NoSQL
NoSQL database stands for “Not Only SQL” or “Not SQL.” Though a
better term would be “NoREL”, NoSQL caught on. Carl Strozz
introduced the NoSQL concept in 1998.
The data is growing continuously and you need to scale the database
regular to handle the data.
The common characteristics of NoSQL databases
1. Not using the relational model
3. Open-source
5. Schema less
Key-value pair storage databases store data as a hash table where each
key is unique, and the value can be a JSON, BLOB(Binary Large Objects),
string, etc.
For example, a key-value pair may contain a key like “Website”
associated with a value like “Guru99”.
It is one of the most basic NoSQL database example. This kind of NoSQL
database is used as a collection, dictionaries, associative arrays, etc.
Key value stores help the developer to store schema-less data. They
work best for shopping cart contents.
Column-based
Column-oriented databases work on columns and are based on
BigTable paper by Google. Every column is treated separately. Values of
single column databases are stored contiguously.
Column based NoSQL database
They deliver high performance on aggregation queries like SUM,
COUNT, AVG, MIN etc. as the data is readily available in a column.
Document-Oriented
Document-Oriented NoSQL DB stores and retrieves data as a key value
pair but the value part is stored as a document. The document is stored
in JSON or XML formats. The value is understood by the DB and can be
queried.
Relational Vs. Document
In this diagram on your left you can see we have rows and columns, and
in the right, we have a document database which has a similar structure
to JSON. Now for the relational database, you have to know what
columns you have and so on. However, for a document database, you
have data store like JSON object. You do not require to define which
make it flexible.
The document type is mostly used for CMS systems, blogging platforms,
real-time analytics & e-commerce applications. It should not use for
complex transactions which require multiple operations or queries
against varying aggregate structures.
Graph-Based
A graph type database stores entities as well the relations amongst
those entities. The entity is stored as a node with the relationship as
edges. An edge gives a relationship between nodes. Every node and
edge has a unique identifier.
What is the CAP Theorem?
CAP theorem is also called brewer’s theorem. It states that is impossible
for a distributed data store to offer more than two out of three
guarantees
1. Consistency
2. Availability
3. Partition Tolerance
Consistency:
Availability:
The database should always be available and responsive. It should not
have any downtime.
Partition Tolerance:
Eventual Consistency
The term “eventual consistency” means to have copies of data on
multiple machines to get high availability and scalability. Thus, changes
made to any data item on one machine has to be propagated to other
replicas.
Disadvantages of NoSQL
No standardization rules
Limited query capabilities
RDBMS databases and tools are comparatively mature
It does not offer any traditional database capabilities, like
consistency when multiple transactions are performed
simultaneously.
When the volume of data increases it is difficult to maintain
unique values as keys become difficult
Doesn’t work as well with relational data
The learning curve is stiff for new developers
Open source options so not so popular for enterprises.
MongoDB
3 db.people.find({name: ’Eve’})
7 db.people.find({name: ’Eve’})
11 db.people.find({name: ’Alice’})
12 // {_id: 789, name: ’Alice’, age: 25}