Important difference between SQL and NoSQL Database

A relational database is a digital database based on the relational model of data and uses Structured Query Language (SQL) and follows ACID (Atomicity, Consistency, Isolation, Durability) property strictly.

SQL databases have been a primary data storage mechanism for more than four decades. Usage exploded in the late 1990s with the rise of web applications and open-source options such as MySQL, PostgreSQL, and SQLite.

NoSQL or Non-Relational databases have existed since the 1960s, but have recently been gaining traction with popular options such as MongoDB, CouchDB, Redis, and Apache Cassandra. They are a data storage system that was designed for unstructured data which does not follow an ACID property like a traditional RDBMS but follows a property called CAP theorem.

We will explore the difference between SQL and NoSQL in this blog post.

Non-Relational (NoSQL) database vs Relational Database(SQL)

NameRelational Database(SQL)Non-Relational Database (NoSQL)
Database ModelRDBMS in the form of Tables (row/column)Graph, Columnar, Key-value pair, Document Wide Column Stores
Data SchemaHas Predefined and Strict SchemaUnstructured data and supports flexible Schema
Transaction SupportYes, supports ACID propertyNo, based on BASE {CAP Theorem}
Foreign KeysYesNo
Query LanguageStructured Query Language(SQL)Unstructured Query Language (UnQL)
Data IntegrityMost SQL databases allow you to enforce data integrity rules using foreign key constraints. The schema forces rules for the database to followThe same data integrity options are not available in the NoSQL database; you can store what you want regardless of any other documents.
JoinsSQL queries offer a powerful JOIN clause. We can obtain related data in multiple tables using a single SQL statement.NoSQL has no equivalent of JOIN
ScalabilityVertically ScalableHorizontal Scalable
ExamplesMySQL, Oracle, SQLite, Microsoft SQL Server, PostgreSQLCassandra, MongoDB, Redis, HBase, Neo4j, CouchDB, RavenDB

As a relational database supports the table-based structure, it is a better option for applications that needs multi-row transactions such as accounting system.

References

SQL-VS NoSQL