SQL versus NoSQL

Two major database types are SQL and NoSQL, that is, relational and non-relational. Choosing the correct type will greatly influence how you develop and manage your data.

SQL

SQL versus NoSQL

What is SQL and what is NoSQL

#


SQL (Structure Query Language)

Relational Databases use SQL which is a standard and widely used database language.

A relational database specifies relationships in the form of tables.

SQL allows you to easily perform CRUD (create, read, update, and delete) operations.


NoSQL (Not Only SQL)

NoSQL are non-relational database systems dedicated to storing very large data sets.

These databases do not require a fixed schema and are therefore easy to change and scale.

NoSQL covers a wide range of database technologies that store structured, semi-structured, unstructured, or polymorphic data.


Development History


SQL

SQL was developed in the 1970s.

Is highly structured and focuses on reducing data duplication.


NoSQL

NoSQL was developed on late 2000s.

Is less structured and focuses on scaling and flexibility by allowing rapid changes.


Schemas and Queries


SQL

SQL databases are structured and have a pre-defined schema (data model).

The schema is designed so that it accomodates the business requirements.

Once created, all data must follow the table layouts and other structures.

Changing the data model is difficult and disruptive to the entire system.


NoSQL

NoSQL databases have dynamic schemas and unstructured data can be stored in multiple ways.

The storage model can be column-oriented, document-oriented, graph-based, or key-value pairs.

This means that documents do not need to follow a defined structure.

Each document can have its own unique structure and fields can be added as you go.


Scalability


SQL

SQL databases are vertically scalable.

This means that a single SQL server can increase its load by adding more CPU, RAM, or SSD capacity.


NoSQL

NoSQL databases are horizontally scalable.

This means that additional servers can be added by sharding which lets you handle higher volumes.

This is the preferred scaling method for large and frequently changing data sets.


Data Access


SQL

Write CRUD queries (SELECT, UPDATE, etc) to access and manage SQL databases.

A direct database connection is needed to construct queries.


NoSQL

NoSQL databases can be accessed using REST APIs.

Performing CRUD operations varies depending on the platform.


Database Examples


SQL

Microsoft SQL Server

MySQL

Oracle

PostgreSQL

Sybase


NoSQL

MongoDB

Redis

CouchDB

Cassandra

HBase

Google BigTable


Advantages and Disadvantages


SQL Advantages

Allows you to write queries with great flexibility.

Supports diverse workloads and allow query engine to optimize queries according to requirements.

With the use of normalization and optimization, a reduced footprint maximizes database performance.

It follows ACID (atomicity, consistency, isolation and durability) properties that guarantees accurate and valid transactions.


SQL Disadvantages

Requires careful up-front database design before developing applications.

Changing the data model in a production database can be difficult leading downtime.

SQL Server is limited in terms of horizontal scaling.

This can be mitigated by replication and failover techniques.


NoSQL Advantages

Supports dynamic schemas with flexible data models

Dedicated to unstructured data which enables unique structures for different data.

Limited built-in database functionality results in high database performance.

Provides high-level APIs for powerful data structures.

Supports seamless horizontal scalability without a single points of failure


NoSQL Disadvantages

Does not support indexing, therefore searching can be slow, especially with large data sets.

NoSQL lacks JOIN and retrieving related data is inefficient.

It has vague interpretations to no support with respect to the ACID properties.

There is no possibility for NoSQL engines to optimize queries.


You may also like



Guides


vsn 3.1