NoSQL vs SQL: Which is Better

Hafad Septiyan
DOT Intern
Published in
3 min readJul 16, 2019
Image source: https://www.geeksforgeeks.org/sql-vs-nosql-which-one-is-better-to-use/

Hello everyone! now i will share about SQL vs NoSQL, most of you are already familiar with SQL database, and have a good knowledge on either MySQL, SQL Server, or other SQL databases. In the last several years, NoSQL database is getting widely adopted to solve various problems.

SQL Database
SQL database is a relational database that makes uses of the Structured Query Language (SQL) to query or communicate with the database. In a relational database, data is stored in multiple tables instead of in a single row. The different tables are related or connected using a common field called the key that is common to one or more tables. Using SQL, the data from multiple tables can be combined to get the information that we need. SQL is used for manage data that has many schemas and relations.

NoSQL Database
NoSQL is a non-relational database, that does not require a fixed schema and easy to scale. These databases are sometimes also referred to as “Not Only SQL” databases. With NoSQL, data can be stored in a schema-less, any data can be stored in any record. NoSQL systems store and manage data in ways that allow for high operational speed. NoSQL is used for Big data and real-time web apps.

What’s the difference

It is helpful to understand the difference between SQL and NoSQL database, and some of available NoSQL database that you can play around with it. So, here we will break down the distinctions and keep our mind when making a decision to use the database.

Language

a. SQL Databases
First time we will talk about SQL, SQL (Structured Query Language) is a programming language that is used to manage data in relational databases. Typically called tables to store data, for defining, query and manipulating the data which is SQL very powerful. Some common RDBMS (Relational Database Management Systems) that use SQL are Oracle, Microsoft SQL Server, Access and others.

b. NoSQL Database
In NoSQL database, queries are focused on collection of documents. You can create documents without having to first define their structure, You can add fields as you go. Sometimes it is also called as UnQL (Unstructured Query Language), so each document can have its own unique structure. Some popular DBMS (Database Management Systems) that use NoSQL are MongoDB, CouchDB, Casssandra, Redis and etc.

Structure and Scalability

Image source: http://sql-vs-nosql.blogspot.com/2013/11/indexes-comparison-mongodb-vs-mssqlserver.html

SQL structure are table based which makes them a better option for applications that require multi row transactions and have many relations.
for scalability in most typical situations, SQL databases are vertically scalable it’s load by increasing the CPU, RAM, SSD, etc, on a single server.

NoSQL structure are document based, there are the collection of key-value pair, documents, graph databases or wide column stores which do not have standard schema, it’s also called non relations database. NoSQL database are horizontally scalable. You can just add few more servers easily in your NoSQL database infrastructure to handle the large traffic, for simple queries, it gives good performance, as all the related data are in single document which eliminates the join operations.

Quick Example Language
Below short example that’s show clearly the difference SQL and NoSQL in language.

CREATE TABLE employee(
name varchar,
email varchar
);
INSERT INTO employee(name, email)
VALUES ("Steve Walker", "walker@gmail.com");

In SQL, the employee would first create this schema before they could add data to the database, where varchar is variable character length.

db.createCollection("employee")db.employee.insert({
name: "Steve Walker",
email: "walker@gmail.com"
})

In NoSQL (Mongo DB) we can just add the name of collection that we use, then to store data we don’t need to create specific schema.

Conclusion

All the technologies are best, to make it better to use is depending on the situations and needs. SQL is good choice for business that has many pre-defined structure and set schemas. For example, applications that require multi-row transactions. NoSQL is strong choice for business that have rapid growth or databases with no clear schema definitions.

--

--