SQL and NoSQL

SQL and NoSQL

Introduction

SQL and noSQL, both are useful while interacting with the database. SQL is a relational database and noSQL is a non-relational database.

SQL and noSQL are used to deal for the same problems in a different manner. SQL uses query while noSQL is document oriented.


SQL database

SQL stands for structured query language. It is useful for querying and manipulating the data in a relational database. It is a structured way of storing data using queries. SQL can be used as a data definition language and data manipulation language. SQL database can be managed by using SQL statements. Such as CREATE, ALTER, DROP, DELETE, UPDATE…etc. SQL databases fit naturally into many venerable software stacks, including LAMP and Ruby-based stacks. SQL is simple and powerful and provide developers to retrieve and manage data stored across multiple tables with a single command.


NoSQL database

NoSQL is a non-relational database. If you have a lot of unstructured data NoSQL database would be helpful for you. NoSQL database are document oriented. They are more like folders assembling related information instead of tables.  NoSQL databases offer more flexibility, which makes them more natural. NoSQL data does not depend on pre-defined tables. A table can be created, and records added to it dynamically. NoSQL is used in modern lightweight, internet enabled applications like social media, chatbots, IoT, messaging, shopping carts, mobile apps, etc.

There are four types of NoSQL databases.

  • Key-value store model – a simple database where each item contains keys and values
  • Column store – stores data in tables, rows, and columns
  • Document database – store data in JSON objects
  • Graph database – stores data in nodes and edges

Difference between SQL and NoSQL database

SQL databaseNoSQL database
SQL is classified as Relational Database.NoSQL is classified as a non-relational database.
It is preferred for complex operations.It is preferred for simple operations.
SQL uses queries for its operation which stores data in a structured form.NoSQL has a dynamic schema for unstructured data.
Data are stored in the form of tables.Data are stored in a document-oriented, key-value store, graph-based and column-oriented
It is vertically scalable.It is horizontally scalable.
SQL follows the ACID principle. (Atomicity Consistency Isolation Durability)NoSQL follows the BASE principle. (Basically available Soft state Eventual consistency)
Examples of SQL databases: MySQL, PostgreSQL, Oracle, MS-SQL, Maria DB, Microsoft Azure, etc.Examples of NoSQL databases: MongoDB, Oracle NoSQL, Redis, Riak, Cassandra, etc.