Types of NoSQL Databases and When to Use Them

Dilshan Hiruna
5 min readMar 16, 2022

What is a NoSQL Database?

NoSQL is an alternative database system for traditional SQL database systems which operates in a non-relational manner that does not require a fixed schema. NoSQL stands for “Not Only SQL”, “Not SQL” or “Non-SQL” which describes storing and managing data without using traditional relational SQL procedures. A NoSQL database is primarily used for distributed data stores with large data storage requirements. NoSQL can be used for both big data and web apps. Big tech companies like Twitter, Facebook, and Google tend to use NoSQL databases over SQL due to the low performance caused by huge volumes of data.

Since NoSQL databases use distributed storage, scaling them up horizontally with commodity hardware is simple. When the volume of data increases, the RDBMS system slows down, which can be solved by scaling up the existing hardware. This procedure, however, is both costly and inefficient. Distributing the data load to separate commodity hardware whenever the load increases is an alternative to this problem.

Features of NoSQL

Non-relational

  • NoSQL databases never use relational models. This means you can’t create direct relations among tables
  • There are no fixed columns. This means you can add/remove or insert/avoid columns as you wish without recreating the table.
  • Data normalization and object-relational mapping are not required.
  • There are no advanced features such as query languages, query planners, referential integrity joins, or ACID properties.

Flexible Schema

  • While SQL manages only structured data, NoSQL can manage structured, semi-structured, or unstructured data.
  • There is no requirement for any kind of data schema definition.
  • Provides heterogeneous data structures within the same domain.

Simple API

  • Querying data is much simpler and avoids human errors
  • APIs make it possible to manipulate and select data at a low level.

Distributed

  • NoSQL databases use the shared-nothing architecture, as a result, there is less coordination and more distribution.
  • The benefit of a distributed database is that data is always available because it is replicated across multiple copies.

When to use NoSQL over SQL?

Development is much faster with NoSQL databases than with SQL

NoSQL databases are a good fit for Agile development practices based on sprints, quick iterations, and frequent code pushes because they often allow developers to control the structure of the data. The process of changing the data structure of SQL databases takes a long time and even exporting and importing data may cause human mistakes.

The amount of data in many applications is too large for a SQL database to handle.

NoSQL databases were designed to handle huge amounts of data. The path to data scalability is well-defined and well-known in NoSQL databases. NoSQL databases frequently use a scale-out strategy, which makes scaling to large data volumes much cheaper than with SQL databases, which use a scale-up approach.

The incapability of SQL in handling traffic and the requirement for zero downtime.

Most NoSQL databases use a scale-out strategy that allows them to scale the amount of traffic they can handle. Scale-out architectures also offer advantages such as the ability to upgrade or change the structure of a database with no downtime.

Types of NoSQL Databases

  • Key-Value Pair Based
  • Column based
  • Document Oriented
  • Graph-based

Key-Value Pair

This is the simplest type of NoSQL database. Each Key is associated with a value. Each Key is distinct and only accepts strings, whereas the value corresponding to that Key can be String, JSON, XML, etc. It is capable of dealing with large amounts of data as a result of this behavior.

Data is stored in Key-Value Stores as a pair consisting of an index key and a value. The index Key is used by Key-Value to store query values. Keys and Values are used to store each item in the database. Each table in a Key-Value store has only two columns, similar to a relational database.

Column based

Data is stored in a set of columns known as column families in column-oriented databases. This means that if a user only wants to run queries on a small number of columns, they can read those columns directly instead of consuming all of the data’s memories. The Column-oriented database is based on the concept of Google’s Bigtable paper.

Although columnar databases are great for analytics, the way they write data makes them difficult to be strongly consistent, as writes of all the columns require multiple disks to write events. This problem does not exist in relational databases because row data is written to disk in a continuous stream.

Document Oriented

Document Stores extend the simplicity of Key-Value Stores by storing values in structured documents such as XML or JSON. Objects in object-oriented software can be easily mapped thanks to document stores.

A schema-free document database eliminates the need to define and adhere to a schema in advance. It enables the storage of complex data in document formats (JSON, XML, etc.). Relationships are not supported by document databases. There is no relational integrity and each document in the document store is independent.

Graph-Based

Graph databases define and store data with their relationships. Each element/data is stored in a node, which is connected to another data/element. Facebook is a common example of Graph database use cases. It maintains the connection between each user and their subsequent connections. A graph database is designed to capture and search the connections between data elements, eliminating the overhead associated with SQL joining multiple tables.

Graph databases are commonly used for social networks, logistics, and spatial data.

Conclusion

In this article, we have discussed what is NoSQL, the features of NoSQL, when to use NoSQL data stores, and four types of NoSQL databases.

NoSQL databases offer an alternative solution to limitations that traditional RDBMS has. And maybe you are a bit confused about whether to choose NoSQL or SQL. The best way to find the best NoSQL database for your application is to identify the requirements that RDBMS does not meet. If an RDBMS meets all of your requirements, you may not need a NoSQL data store.

--

--