Relational Databases and Non-Relational Databases

Nugroho
3 min readMay 7, 2024

--

What is Relational and Non-Relational Databases?

Imagine a database as a filing cabinet. If we play the role of managing the filing cabinet, our job is to organize everything in it neatly.

Starting from assigning categories to each type of archive, giving each folder in the cupboard a unique number, to arranging them in a certain order.

In this article and probably the next few articles, I will explain about the world of databases. Because this is one of my favorite topics in the data field. So, let’s get started!

What is Databases?

A database is a collection of data that is stored in a computer and can be accessed in various ways. One of the advantages of using a database is that it reduces the amount of time we spend managing data.

There are two main types of databases, namely relational databases and non-relational databases. For relational databases I like PostgreSQL, while for non-relational ones I like MongoDB. Just saying :).

These two databases are different and have their own advantages and uses. Here is the explanation.

What is Relational Databases?

A relational database is a type of database that organizes data into tables with rows and columns, where each row represents a record, and each column represents a field (tabular).

This structure makes it possible to query and manipulate data easily using Structured Query Language (SQL).

Some popular SQL database systems are Oracle, Microsoft SQL Server, PostgreSQL, MySQL, and MariaDB.

What are Non-Relational Databases?

A non-relational database, also known as a NoSQL database, is a type of database that does not use the traditional table-based relational structure (non-tabular).

Instead, non-relational databases use various data models, such as document data stores, column-oriented databases, key-value stores, document stores, and graph databases.

Some popular No SQL database systems are MongoDB, Google Cloud Firestore, Cassandra, Redis, Apache HBase, and Amazon DynamoDB.

The differences between relational databases and Non relational databases?

Structure

Structure refers to how data is stored in a database system. SQL databases are table-based with rows and columns or tabular, while NoSQL databases can be document-oriented, key-value pairs, or graph structures.

Performance

Although relational databases offer strong data consistency, sometimes their performance can be a little slow for some special usage situations.

In contrast, non-relational databases tend to provide faster performance, especially for use cases involving big data and real-time processing.

Query Language

SQL databases use SQL (Structured Query Language) such as PostgreSQL or MySQL.

NoSQL databases use JSON (JavaScript Object Notation), XML, YAML, or binary schema, facilitating unstructured data such as MongoDB.

SQL has a fixed defined schema, while NoSQL databases are more flexible.

When to use SQL or No-SQL?

SQL databases are very suitable for use in situations where the data must be structured. Some examples of SQL database use cases are:

  1. Finance: Financial institutions often need SQL databases to manage their transaction data and customer records.
  2. Retail: Retail businesses often need SQL databases to manage complex data such as relationships between products, shipping, sales, customer, and supplier information.

Meanwhile, NoSQL databases are more suitable in situations where data is flexible and dynamically adaptable. Examples of NoSQL database use cases include:

  1. Social media: NoSQL databases are ideal for storing unstructured data such as user profiles, posts, and interactions between users on social media platforms.
  2. Gaming: In the gaming industry, NoSQL databases are often used to store frequently changing and dynamic player data, ratings, and game analytics.

That’s a brief explanation of the difference between SQL (relational) databases and NoSQL (non-relational) databases.

This is just a summary of what I have learned.

Next, I will make an explanation about the use of queries in SQL and NoSQL.

--

--

Nugroho

Enthusiastic about data, Machine Learning, web scraping, Python, SQL & data viz, I also talk about money at www.cashnug.com