Relational (SQL) vs non-relational (NoSQL) databases

A comparison of relational databases and the different types of non-relational databases

IcePanel
4 min readJul 12, 2023

⚡ Tl;dr

  • Relational databases, sometimes called SQL databases, store data in tables with rows and are good at maintaining reference integrity and data consistency.
  • NoSQL databases are designed to have flexible schemas, making them great for modern applications where data structures evolve quickly. There are a few types of NoSQL databases, as listed below.
  • Document store
  • In–memory cache
  • Graph database
  • Search engine database
  • Time series database
  • Key-value database
  • Wide-column database

🚀 Let’s kick-off

Relational and non-relational are the two popular types of databases that are most widely used. They are very different in their features and trade-offs and appropriate for different use cases.

In this article, we’ll discuss the differences between relational and non-relational databases and then dive into the various non-relational database types you can choose.

Relational databases

Relational databases, sometimes called SQL databases or Relational Database Management Systems (RDBMS), store data in tables with columns and rows.

The main advantage of relational databases is the integrity of references which means the data is always accurate and consistent. Using primary/foreign keys ensures that when a row is added or deleted, any references to other tables must also be valid and exist. This prevents orphaned records where the reference points to a row that does not exist, which can cause errors in your application.

Querying relational databases is done by using Structured Query Language (SQL), which is a robust language designed to create, retrieve, update and delete rows of a table.

Example relational databases:

Non-relational databases

NoSQL databases are designed to have flexible schemas, making them great for modern applications where data structures might evolve quickly. They typically offer an easy development experience due to the JSON-like format and lack of structure imposed by tables, rows and columns.

NoSQL databases scale horizontally, allowing them to operate at a much larger scale and performance than relational databases. Not worrying about the accuracy of relations makes it much easier to shard non-relational data sets.

There are various types of NoSQL databases which we’ll cover next.

Document store

Document databases store and query documents in a key-value JSON-like structure, making them easy to work with. The flexible and hierarchical nature of these documents provides straightforward mutation of the data structure as it evolves over time. Document databases typically scale horizontally, allowing them to scale to large datasets.

Examples of document stores:

In–memory cache

In-memory caches are key-value stores designed to minimize latency by storing the data in the main memory, removing the need for slower disks or SSDs. They are typically used as a caching mechanism and can persist data on disks by periodically taking memory snapshots.

Examples of in-memory cache:

Graph database

Graph databases are often the most complex type of database as they’re designed to store and query relations between objects. They store data in a graph-like structure allowing efficient querying of related and inter-connected data. Relationships between nodes are persisted in the database, making it very fast to traverse the graph.

Examples of graph databases:

Search engine database

Search engine databases are specialized databases for indexing and searching large amounts of data for similar characteristics. They are optimized for operations such as full-text search, ranking based on similarity and complex search expressions. They are often used as secondary databases, indexing data from a primary database and making it searchable.

Examples of search engine databases:

Time series database

Time series databases (TSBD) are optimized for storing sequential data collected over time, usually associated with a timestamp. They are efficient at collecting, storing and querying large and high-velocity data sets and are great for analyzing how data changes over time. Time series databases are usually append-only.

Examples of time series databases:

Key-value database

Key-value databases store a collection of key-value pairs that can hold simple or complex object types such as strings, numbers or objects. Due to its simple and optimized key-based structure, it’s highly performant and can reach scales that other database types cannot.

Examples of key-value databases:

Wide-column database

Wide-column stores are conceptually similar to relational databases but organize data by columns instead of rows. This allows them to store tables with many columns and handle massive data sets.

Examples of wide-column databases:

🏁 To wrap up

There are many factors and trade-offs involved when making a decision to choose a specific type of database. It’s essential to research and experiment with different technologies to find the right solution for your use case.

Let us know if we missed your favourite database!

Stay chill 🧊

--

--

IcePanel

🧊 Align on technical decisions across your software engineering and product teams icepanel.io 🔗