NoSQL Databases


  • NoSQL can be referred to as non relational databases.
  • NoSQL provides the process of storage and retrieval of data which is different than the relational databases. For example: NoSQL can store the data in the form of document.
  • NoSQL consists of data like user information, social graphs, geographic location data and other user-generated content.
  • Examples of NoSQL databases: MongoDB, Cassandra.

Advantages of NoSQL

  • NoSQL supports non relational databases and is also called as not only SQL.
  • NoSQL has a dynamic schema in which new data is added automatically.
  • It is highly scalable.
  • NoSQL provides the support for distributed computing.

Disadvantages of NosQL

  • NoSQL does not have the defined standard.
  • NoSQL has a limited capability of queries.

CAP Theorem for NoSQL

CAP Theorem is also known as 'Brewers Theorem', which states:

1. Consistency:
Database should remain consistent even after the execution and all nodes in the network should see the data at the same time.

2. Availability:
It refers that the system is always available without any downtime.

3. Partition tolerance:
The system can continue to operate even if sudden partitioning occurs due to the network failure. For example: In case of network failure, if one server stops working, the other can serve the request.

Types NoSQL Database

The different types of NoSQL databases are as follows:

1. Key-value pair:
Every item in the database is stored as an attribute name (key) and linked with value. Key-value pairs are stored in the form of array.

2. Wide-column stores:
Instead of storing data in rows (relational tuples), the databases are designed for storing the data in the section of columns. Wide-column store provides high scalability and improves the performance of the system.
Examples: Hbase, BigTable, HyperTable.

3. Document Database:
Document databases work on key-value pair and contain more complex data. Each document is assigned a unique key which helps to retrieve the document.
Examples: MongoDB, CouchDB.

4. Graph Database:
Graph database is based on graph theory and especially designed for the data elements which are interconnected in the network.
Examples: Neo4j, Polyglot.


SQL stores data in the table.NoSQL stores data in the form of document, key-value pairs etc.
SQL provides standard platform to run complex queries.NoSQL cannot provide any standard platform to run complex queries.
Supports the structured and organized data.Supports unstructured data.
SQL works on ACID properties.NoSQL follows CAP theorem.
Data and its relationships are stored in separate tables.NoSQL does not have any pre-defined schema.
Examples: Oracle, SQLite.Examples: MongoDB, Cassandra.

Amazon DynamoDB

  • Amazons DynamoDB is a NoSQL database service, which provides fast performance.
  • DynamoDB data model consists of table, items and attributes.
  • Each attribute of DynamoDB is represented as a name-value pair.
  • Amazon DynamoDB is a web service, which uses HTTP as a transport layer service.
1. Primary key:
To create a table, a user needs to define the primary key column name, which identifies the items in a table separately.

2. Partition key:
A primary key which has only one attribute is known as the partition key.  
DynamoDB  can use the partition key as input to the hash function for only internal use.

The two attributes of composite primary key are as follows:
1. First attribute is a sort key.
2. Second attribute is a sort key.

All items with same partition key are stored together and  sorted out by using sort key value.

Data Indexing in Amazon DynamoDB

  • Amazon DynamoDB creates and maintains indexes for the primary key attributes, which helps in efficient access to data present in the table and also for the purpose of data retrieval.
  • DynamoDB creates a table with a composite primary key, which supports one or more secondary indexes in the table.
The two types of secondary indexes are:

1. Global secondary index:
It is an index with a partition key and a sort key.

2. Local secondary index:
It is an index having the same partition with different sort key.