SQL vs. No SQL

Learn what is the difference between SQL and No SQL databases.

Data and Databases

 
Data can be the facts related to objects. For example, a person's data can have age, height, weight, skin color, hair color. eye color and so on. A car's data can have made, model, year, and color. 
 
A database is a systematic collection of data. A database management system (DBMS) is a database product (software) that is used to manage databases. Some popular databases are SQL Server, Oracle, NoSQL, and DB2.
 
There are several types of DBMSs such as relational, network, graph, document, NoSQL, and object. Learn here more about Types of Database Management Systems.  
 

SQL

 
SQL stands for Structured Query Language and it therefore is not a database itself but only a query language. SQL is a popular query language to work with relational database management systems (RDBMS). SQL allows you to store, update, delete and retrieve data from relational database management systems.
If you're not familiar with SQL, I highly recommend reading this article, What is SQL.
 

SQL and RDBMS

 
Relational databases have following two characteristics:
  • Data is stored in database tables (rows and columns) by following a strict data schema (=structure). A table record represents an object. A column defines the attribute of the object and a row represents the value. 
  • Data is distributed across multiple tables which are connected via relations. 
Strict data schema 
  • Data is stored in tables.
  • Each table has clearly defined structure.
  • You can't add records which don't adhere to this schema. 
Relations 
  • You split data into multiple tables to avoid data duplication.
  • Each table will only hold data that is not stored in one of other tables.  
 

No SQL

 
No SQL databases follows the approach opposite to that of SQL, that means there is no tabular data. Here are the key attributes of NoSQL databases: 
  • No Schemas.
  • No Relations.
  • You can put data of different structure into the same collection.
  • Data is stored like JSON data, so there is no need to worry about schema.
  • You put related data into same collection.
  • No need to join multiple table/collections. No SQL databases don't know the concept of joining tables/collections.
  • You can manually achieve this behavior but it's not a typical flow. 
  • Data is duplicated across collections, so it can be used as per need.
Types of NoSQL databases 
  • Document: Helpful for content management and mobile apps. e.g. MongoDB
  • Data model based on associative array (map/dictionary) e.g. Dynamo
  • Graph: Data organized in nodes and edges e.g. Neo4j
  • Column: Wide column storing and arranging data in columns instead of rows e.g. Scylla. 
Learn more about NoSQL databases here, What are NoSQL Databases.
 

The Right Choice 

 
There is no clear winner! Both are viable solutions to different problems and comes down to the data and application in the end. It also depends on your application requirements. While SQL databases are popular due to the nature of their easy to use and universal SQL language, NoSQL database can present good solution for high performance object storages.
 
 

When to chose SQL vs NoSQL

 
SQL databases are easy to use and provide SQL language that is easily used in applications. SQL is also a common language to learn and you can easily find SQL resources. SQL databases requires you to have a clear schema and make sure data types do not change frequently.
 
NoSQL is good for objects documents, and other non SQL data types. NoSQL is also useful when data requires high throughput.
 
Continue reading here: Advantages of using NoSQL Databases.