7 minutes read

The idea of storing data in tables is pretty straightforward, but it might not be the most suitable way of storing unstructured data. So for this one and many other cases, NoSQL databases are often used. They can also improve performance and in some ways facilitate development. NoSQL databases became popular when the amount of data increased and relational data were not able to handle it properly.

What is a NoSQL database?

The title "NoSQL" was introduced by Carlo Strozzi in the Strozzi NoSQL database. This database was relational but didn't use SQL for its queries.

Nowadays, "NoSQL" is used as an umbrella term for many databases, usually non-relational. "NoSQL" stands for "Non-SQL" or "Not only SQL". The main difference from SQL-like databases is that NoSQL databases don't store data in relational tables.

Which kinds of NoSQL databases exist?

The name 'NoSQL' is very vague. It doesn't say anything about how exactly this database works. However, at the moment, there are four most popular types of NoSQL databases:

  • Key-value stores: these databases map key to a value, implementing a hash table. This data structure is also known as a dictionary. They are usually used to store information that needs quick access, for example, cache. Examples: Redis, DynamoDB.

  • Wide-column stores: these databases use tables and rows as relational databases. But the difference is that the format and names of columns might change from row to row in the wide-column store. They might be treated as two-dimensional key-value stores and are usually used for storing versatile objects. Examples: BigTable, Apache HBase.

  • Document databases: originally were created to store documents in XML format. But nowadays, they can work with different formats of data such as JSON, YAML, BSON, and others. Examples: MongoDB, Apache CouchDB.

  • Graph databases: databases that operate with nodes and edges (relationships). They are used to represent data where the most important part is relationships between objects. Graph databases are very useful in identifying patterns in semi-structured and not structured data. Examples: InfiniteGraph, Neo4j.

You can read more about these types of databases in the next topics.

With time the amount of data that needed to be stored increased drastically. For example, according to the research in ten years (2010 -- 2020) the amount of data worldwide increased by 32 times.

Data volume in years

At the same time the cost of storing devices decreased:

Hard drives cost

source

With the increasing amount of less structured data, it became more difficult to create templates to store it in relational databases. Thereby NoSQL databases became more and more popular in the modern world of development.

BASE principles

NoSQL databases became popular in the conditions of continuously increasing amounts of data. They had to offer simpler horizontal scalability (the system should be able to handle bigger loads only by adding new machines). Usually, NoSQL databases don't offer consistency between the instances of the database, but instead, they offer eventual consistency. It means that eventually, the data stored on every instance of the machine will be the same. The time needed for a database to become consistent is usually expressed in milliseconds.

In general, NoSQL databases follow BASE principles: Basically Available, Soft state, and Eventual consistency. The Basically available principle means that the database is available at all times. The Soft state means that the state of the system can change even without input data, for example, for making the system consistent.

When to use NoSQL databases?

NoSQL databases were created when relational databases became too complicated. And this is still the biggest reason to use a NoSQL database. If the project needs to operate with semi-structured or not structured data, NoSQL will be a good choice. Besides, NoSQL database can have other benefits. For example, some NoSQL databases were designed to handle big data, and they have all kinds of optimizations helping to make working with them more effective.

Development time is usually shorter for the NoSQL databases. In the modern world, it might also be an important point to consider.

When not to use NoSQL databases?

NoSQL databases, in general, don't offer consistency, and sometimes it might be very important, for example, in applications that handle bank transactions.

The other questionable moment is the query language. If lots of complicated queries, including joins, are required, usually NoSQL databases are not a good choice because the query interface is quite limited. This is changing, and query interfaces are becoming more and more sophisticated, but at the moment, relational databases are still much better in this regard.

NoSQL databases are more agile than relational databases, and because of it, they have become very popular. They allow developers to work easily with unstructured data and offer eventual consistency.

Conclusion

There is a wide range of different databases named NoSQL databases. When developers are choosing a database for their projects, NoSQL databases definitely should be taken into consideration, especially when working with unstructured data. NoSQL databases don't have to be consistent but usually they eventually become so.

Read more on this topic in Relational vs. Non-relational Showdown on Hyperskill Blog.

62 learners liked this piece of theory. 0 didn't like it. What about you?
Report a typo