Non-relational or NoSQL databases were born out of the rigidity of traditional relational or SQL databases, which use tables, columns, and rows to establish relationships across data.

NoSQL database is attracting users from all over the world due to its exceptional behavior and Big Data distributed processing capabilities for unstructured data. In this article, we will discuss in detail NoSQL databases and their types.

Here are the four main types of NoSQL databases:

  • Document Database
  • Key-value store Database
  • Column-0riented Database
  • Graph Database

Also Read: Is NoSQL is a better Alternative for SQL?

Document Databases

A Document database stores data in JSON, BSON, or XML documents (not Word documents or Google docs, of course). In a document database, documents can be nested. Particular elements can be indexed for faster querying.

Documents can be stored and retrieved in a form that is much closer to the data objects used in applications, which means less translation is required to use the data in an application. SQL data must often be assembled and disassembled when moving back and forth between applications and storage.

Example of JSON like document describing a book:

[
    {
        "year" : 2013,     //fields c   
        "title" : "Turn It Down, Or Else!",
        "info" : {          //Field containt array of subdocuments
            "directors" : [ "Alice Smith", "Bob Jones"],  
            "release_date" : "2013-01-18T00:00:00Z",
            "rating" : 6.2,
            "genres" : ["Comedy", "Drama"],
            "image_url" : "http://ia.media-imdb.com/images/N/O9ERWAU7FS797AJ7LU8HN09AMUP908RLlo5JF90EWR7LJKQ7@@._V1_SX400_.jpg",
            "plot" : "A rock band plays their music at high volumes, annoying the neighbors.",
            "actors" : ["David Matthewman", "Jonathan G. Neff"]
        }
    },
    {
        "year": 2015,
        "title": "The Big New Movie",
        "info": {
            "plot": "Nothing happens at all.",
            "rating": 0
        }
    }
]

Advantages

The document model works well with use cases such as catalogs, user profiles, and content management systems where each document is unique and evolves over time.

Document databases enable flexible indexing, powerful ad hoc queries, and analytics over collections of documents.

Use Cases of Document Database

 Document stores are great for the following types of applications:

  • Large eCommerce platforms (Like Amazon)
  • Blogging sites (such as Twitter)
  • Content management systems (WordPress, windows registry)
  • Analytical platforms

Examples of Document databases

Examples of Document databases are – MongoDB, OrientDB, Apache CouchDB, IBM Cloudant, CrateDB, BaseX, and many more.

Key-Value Stores

The simplest type of NoSQL database is a key-value store. Every data element in the database is stored as a key-value pair consisting of an attribute name (or “key”) and a value. In a sense, a key-value store is like a relational database with only two columns: the key or attribute name (such as the state) and the value (such as Alaska).

The value in a key-value store can be anything: a string, a number, but also an entirely new set of key-value pairs encapsulated in an object. Figure 6 shows a slightly more complex key-value structure. Examples of key-value stores are Redis, Voldemort, Riak, and Amazon’s Dynamo.

key-value database structure

Advantages of Key-Value Database

  • As data is increasing steadily in quantity, key-value stores provide the speed needed to manipulate this data at high proficiency.
  • The major advantages of key-value stores are scalability, speed, and flexibility.
  • Key-value stores handle size well and are good at processing a constant stream of reading/write operations.

Use Cases of Key-value Database

Good Key-Value Database Use Cases Include:

  • Scalable data.
  • Profiles, preferences, and configurations.
  • Cache management.
  • Blockchain implementation.
  • Multimedia storage or large objects (video, images, audio, etc.)

Examples

DynamoDB, Riak, Redis are a few famous examples of Key-value store NoSQL databases.

Graph Database

As its name suggests, a graph database is modeled based on graphs. These graphs represent complex, interconnected information as well as the relationships within it in a clear way, and they store this data as a large, coherent data set. 

Compared to a relational database where tables are loosely connected, a Graph database is multi-relational in nature. Traversing relationships is fast, as they are already captured into the DB, and there is no need to calculate them.

Graph representation of table in Social Networking site

Advantages of Graph Database

  • Query speed is only dependent on the number of concrete relationships, and not on the amount of data.
  • Results in real-time.
  • Clear and manageable representation of relationships.
  • Flexible and agile structures.

Use cases of Graph Database

Graph-based NoSQL databases are usually used in:

  • Fraud detection
  • Graph-based search such as knowledge graph
  • Network and IT operations
  • Social networks, etc

Examples of graph base NoSQL databases are Neo4j, ArangoDB, and OrientDB.

Column-Oriented Databases

While a relational database stores data in rows and reads data row by row, a column store is organized as a set of columns.  Columns are logically grouped into column families. Column families can contain a virtually unlimited number of columns that can be created at runtime or while defining the schema. Read and write is done using columns rather than rows. Column families are groups of similar data that is usually accessed together. 

Advantages of Column-oriented Database

Column-Oriented databases can quickly aggregate the value of a given column (adding up the total sales for the year, for example). Relational databases stores different rows in different places on the disk while columnar databases store all the cells corresponding to a column as a continuous disk entry, and benefit from more efficient compression, making reads even faster.

Columns are often of the same type and benefit from more efficient compression, making reads even faster. Columnar databases can quickly aggregate the value of a given column (adding up the total sales for the year, for example).

Use Cases of Column-oriented Database

Developers mainly use column databases in:

  • Content management systems and analytics.
  • Blogging platforms
  • Systems that maintain counters
  • Services that have expiring usage
  • Systems that require heavy write requests (like log aggregators)

Examples of Column-oriented Database

HBase, Cassandra, HBase, Hypertable are NoSQL query examples of column-based databases.

Conclusion

While Selecting a NoSQL Database, you should also consider the database technology, its configuration, and available infrastructure, proposed architecture of your application, budget as well as the skill set available at your organization, etc.

Once all such questions are answered, the project team should shortlist a couple of NoSQL Database vendors and perform a Proof of Concept (Experiment through a pilot project) to evaluate the technology and benchmark the performance in order to finalize the selection.

We hope this article helps you get an idea of which NoSQL database type to choose for your application or project. More supported data models within one database mean more versatility for you and to the end-user, in the way you should store your data.