By the end of this decade, our digital data universe will grow from 4.4 zettabytes today to about 44 zettabytes, or 44 trillion gigabytes.
OK, so we know you’re here to weigh the technical differences between relational and non-relational databases. But before we dive in, we need to define a few important details. You need to determine what priority scalability represents for your particular model.
In order for your data model to be as accurate as possible, you need to ask the right questions. Otherwise, your solution may not be the best fit for your problem. If you already have this well defined, go ahead.
What is a relational database?
A relational database is a digital database based on the relational data model, as proposed by E. F. Codd in 1970, an intuitive and straightforward way of representing data in tables . Relational databases store and provide access to data points that are related to each other.

In a relational database, each row in a table is a record with a unique identifier called a primary key. The columns in the table contain the attributes of the data, and each record usually has a value for each attribute, making it easier to establish relationships between the data.

There are several systems that you can use to manage relational databases, these are known as Relational Database Management Systems (RDBMS). The most popular among them is MySQL , but we also have other options such as Oracle Database, Microsoft SQL Server, and IBM DB2.
The vast majority of RDBMS offer the option of using SQL (Structured Query Language) to query and maintain the database.
It is very common to confuse a database with a DBMS, but you may be surprised to know that MySQL is not a database .
Types of relationship
One of the advantages of a relational database is that once you have your data stored in clearly defined tables, you can connect or relate data between different tables. To be able to identify these relationships, you need to examine the data and have an understanding of the business rules that apply to the data and tables.
When you create relationships, you always work with two tables at a time. One table is called the main table or parent table , and the other is the related table or child table .
The three types of relationships you will find in relational databases are 1-to-1, 1-to-many, and many-to-many. The relationships are described below.
- One-to-one (
1...1
): Both tables can have only one record on each side of the relationship. Each primary table value refers to only one (or no) record in the related table. - One-to-many (
1...n
): The primary table contains only one record that can relate to none, one, or many records in the related table. - Many-to-many (
n...n
): Each record in both tables can relate to any number of records (or no records) in the other table. Many such relationshipsn...n
require a third table, known as a linking table or associated table, because relational systems cannot directly accommodate the relationship.
What is a non-relational database?
A non-relational database is any database that does not follow the relational model provided by traditional relational database management systems (RDBMS). This category of databases is also known as NoSQL databases.
The most popular ones being MongoDB , DocumentDB , Cassandra , Couchbase , HBase , Redis , and Neo4j . These databases are generally grouped into four categories: Key-value stores, Graph stores, Column stores , and Document stores .
Types of non-relational databases
Key-value stores

As the name suggests, in a key-value database , data is represented as a collection of key-value pairs. These are also known as associative arrays, organized in rows. These databases store data as a hash table with a unique key and a pointer to a particular data item. Similar to traditional hash tables, this type of database allows data to be stored and retrieved using keys.
Key-value databases are used whenever data is queried by precise parameters and needs to be retrieved quickly.
Graph stores
Although key-value databases can handle large amounts of data, they are designed for a high-level (low-depth) view of the data. Graph databases are able to maintain a minimal storage footprint even with a greater data depth than other types of databases.

Graph NoSQL databases are specifically designed to handle very large sets of structured, semi-structured, or unstructured data. They help organizations access, integrate, and analyze data from multiple sources.
Widely used when it is necessary to analyze data from social networks, for example.
Column stores
Columnar data storage, also known as column family, uses columns to store data instead of rows as in the relational model. Both row-based and column-based DBMSs use SQL as the query language, but column-oriented DBMSs can offer better performance.

Column store databases use a concept called a keyspace . A keyspace is like a schema in the relational model. The keyspace contains all the column families (like tables in the relational model), which contain rows, which contain columns.
Document stores
Document store databases , also called document-oriented DBMS, are characterized by their schema-free data organization.
This means that records do not need to have a uniform structure, i.e. different records can have different columns. Value types can be different for each record, columns can have more than one value (arrays), and records can have a nested structure.

Documents are usually stored in a structure similar to JSON, which makes the programmer’s life easier, with JSON being one of the most common data structures, especially when working with Javascript .
What is the difference between relational and non-relational databases?
Relational databases such as MySQL, PostgreSQL, and SQLite3 represent and store data in tables and rows. They are based on a branch of algebraic set theory known as relational algebra. Non-relational databases such as MongoDB represent data in collections of JSON documents.
Relational databases use Structured Query Language (SQL), making them a good choice for applications that involve managing multiple transactions. The structure of a relational database allows you to link information from different tables through the use of foreign keys (or indexes).
If you are dealing with a phenomenal amount of data, the complexity of the relational database and the queries required will also increase accordingly. In this situation, you may need to consider using a non-relational database. A non-relational database can store data without an explicit, structured mechanism for linking data from different tables to each other.
Disadvantages of relational databases
While relational databases are great, they come with trade-offs . One of them is ORM Impedance Mismatching , because relational databases were not initially designed with OOP languages in mind.
The best way to avoid this issue is to design your database schema with referential integrity. Therefore, when using a relational database with OOP (like Ruby or Java), you have to think about how to set up your primary and foreign keys, the use of constraints (including cascading delete and update), and how to write your migrations.
Disadvantages of non-relational databases
In non-relational databases like MongoDB , there are no joins like in relational databases. This means you need to perform multiple queries and join the data manually within your code.
Since Mongo does not automatically treat operations as transactions in the same way that a relational database does, you must choose to create a transaction and then check it out, commit it , or roll it back manually.
My suggestion is, analyze the data you are going to store. Ask the right questions to find out what data model you will need. Choosing the programming language to write your application and using a specific database will put your application on the right track.
If you liked the article, be sure to comment and share. And so you don’t miss any news here on the blog, sign up for the newsletter and receive exclusive content every week!
Deixe um comentário