Difference between SQL and NoSQL databases

Created at 06-Jan-2024 , By samar

In this post we will learn about the differences between SQL and NoSQL databases. SQL databases known as relational databases and NoSQL databases are Non-relational.

SQL (Relational) database have relationships between tables using the primary key and foreign key. No-SQL databases do not have any relationship between tables (tables are known as collections in No-SQL databases).

SQL databases use structured query language (SQL) and have predefined schema (table structure) and No-SQL databases have dynamic schemas for unstructured data and have their own query language.

SQL databases are vertically scalable and No-SQL databases are horizontally scalable. Which means, SQL databases scale vertically by adding resources to a single server for increased performance. NoSQL databases scale horizontally by distributing data across multiple servers, accommodating growing workloads and enhancing fault tolerance.

SQL databases are table based, while No-SQL databases are document, key-value, graph or wide-column stores.

Examples of SQL databases are MySQL, PostgreSQL, Microsoft SQL Server, SQLite, Oracle Database. Example of No-SQL databases are MongoDB, Cassandra, Redis and Firebase.

SQL databases used structured query language which is a language used to interact with SQL databases and No-SQL databases uses their own query language like mongodb uses own (MQL) MongoDB Query Language and Cassandra uses own CQL (Cassandra Query Language).

Example Query for SQL Databases :

MySQL : SELECT * FROM table;

PostgreSQL : SELECT employee_id, first_name, last_name FROM employees WHERE department = 'IT';

Example Query for No-SQL Databases :

MongoDB: db.users.find({ _id: ObjectId("609c8721a92bfa0c5e9e8e2f") })

Cassandra: INSERT INTO EMPLOYEE(empId,name,dept) VALUES (0001, 'Clark', 'Sales');

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.