Home » MongoDB » Difference between SQL and NoSQL

Difference between SQL and NoSQL

In this tutorial we will discuss difference between SQL and NoSQL Database

MongoDb Installation


Let us consider for an employee management database we have a table called EMPLOYEE table that has relation between DEPARTMENT table and also with the ADDRESS table with the help of foreign key.if we want to have all the details for the particular employee including the Department and address details we need to write joins and then only we will get all the details.joins are complex and will take some time to execute our query.

Now lets come to nosql,so in nosql what happens all this details for the Employee, Department and address are getting stored as a single record.Mostly in NoSQL databases there are no relationships and that's why you don't need to write joins.So the execution of the query in the NoSQL database is a lot faster than the SQL database.

Now in NoSQL databases relationships are not preferred.but that doesn't mean that NoSQL databases doesn't support relationships.There are some NoSQL databases which support relationships as well but in NoSQL databases the relationships are not preferred because not having the relationship between table is the biggest advantage of the NoSQL database. If you have relationship in NoSQL database then why to migrate from SQL to NoSQL database.

SQL databases follow ACID properties (Atomicity, Consistency, Isolation and Durability) whereas the NoSQL database follows the Brewers CAP theorem (Consistency, Availability and Partition tolerance).

SQL databases are vertically scalable. This means that you can increase the load on a single server by increasing things like RAM, CPU or SSD. But on the other hand NoSQL databases are horizontally scalable. This means that you handle more traffic by sharding, or adding more servers in your NoSQL database. It is similar to adding more floors to the same building versus adding more buildings to the neighborhood. Thus NoSQL can ultimately become larger and more powerful, making these databases the preferred choice for large or ever-changing data sets.


Previous Next Article
comments powered by Disqus