MongoDB NoSQL Database

In this tutorial you will learn about the MongoDB NoSQL Database and its application with practical example.

What is NoSQL Database?

The acronym NoSQL stands for Not Only SQL”. NoSQL Database is a category of database management systems that does not compliant with the traditional relational DBMS (RDBMS) rules, and does not uses the traditional SQL to query database. NoSQL Databases are used to store large volume of unstructured, schema-less non-relational data.

NoSQL Database Type

There are 4 basic types of NoSQL databases –

Key-Value Stores :- It is simplest type of NoSQL database. In key-value storage database, data is stored in a big hash table of keys & values, means for every key there exists an associated value. Here each key is unique and the value can be string, JSON, BLOB (Binary Large OBjec) etc. Example- Riak, Redis, Amazon S3 (Dynamo).

Column Oriented Database :- In Column Oriented databases, values of a single column are stored in contiguous block. These type of databases mainly used to store large data sets. Each of the column is treated separately and data is stored in column specific files. Column Oriented databases provides better query performance over large data sets. Example- HBase, Cassandra.

Graph Oriented Database :- A graph database is a collection of nodes and edges, which is used to represent and store data. In Graph Database, a node is used to represents an entity (such as a employee or business) and an edge is used to represents a relationship or connection between two nodes, every node and edge have a unique identifier associated with them. Example- Neo4J, OrientDB, Titan.

Document Oriented Database :- In Document Oriented Database, data is stored as documents and a document can contain many different key-value pairs, or key-array pairs, or even nested documents. Every document have a unique key associated with them. Example- MongoDB, CouchDB.

NoSQL Advantages (Pros)

  • High availability
  • High scalablity
  • Flexible and dynamic database schema.
  • No complex joins or relationship
  • High performance
  • Works perfect with high volumes of structured, semi-structured, and unstructured data
  • Reduced cost
  • Supports distributed computing infrastructure

NoSQL Disadvantages (Cons)

  • Lack of Standardization
  • Lack of Security
  • Lack of Support

Difference Between NoSQL & RDBMS

RDBMS NoSQL
Structured and organized database schema Database schema is dynamic, unstructured and flexible
Database schema needs to be defined beforehand Database schema is dynamic and need not be defined beforehand
Table based databases NoSQL databases can be document oriented, key-value pairs, graph databases or column oriented.
Vertically scalable Horizontally scalable
Best fit for transaction intensive applications It does not support complex complex transaction
It emphasizes on ACID properties ( Atomicity, Consistency, Isolation and Durability) It follows the Brewers CAP theorem ( Consistency, Availability and Partition tolerance )
It uses structured query language (SQL), Data Manipulation Language (DML), Data Definition Language (DDL) for defining and manipulating the data. Query language varies from database to database.
Examples- MySql, Oracle, Sqlite, Postgres and MS-SQL. Examples- MongoDB, Redis, Hbase, RavenDb, Cassandra, Neo4j and CouchDb

In this tutorial we have learn about the MongoDB NoSQL Database and its application with practical example. I hope you will like this tutorial.