It is a well known fact that SQL databases have ruled the world of data technologies and have been the primary source of data storage for over 4 decades. Generally the SQL databases are used, mainly for accessing relational databases.
Oracle and Microsoft SQL Server ruled the segment, but as the Web development market paced up, there came a shift towards usage of open source databases like MySQL, Postgres etc. But RDBMS was still the first choice.
Soon enough data started growing exponentially and scalability became a major issue, at that time NoSQL rolled in to save the day.
One of the cool facts about NoSQL databases is that they existed since 1960, but in the recent times they have gained more popularity especially for the scaling feature provided by the same.
The major difference between MongoDB and SQL Databases is the way they handle data. In SQL databases, data is stored in form of traditional 2 dimensional row-column structure while in MongoDB rich data document model is followed, which allows storage of any type of data.
Let us see some of the key differences between MongoDB and other SQL databases :
|SQL Database||NoSQL Database (MongoDB)|
|Relational database||Non-relational database|
|Supports SQL query language||Supports JSON query language|
|Table based||Collection based and key-value pair|
|Row based||Document based|
|Column based||Field based|
|Support foreign key||No support for foreign key|
|Support for triggers||No Support for triggers|
|Contains schema which is predefined||Contains dynamic schema|
|Not fit for hierarchical data storage||Best fit for hierarchical data storage|
|Vertically scalable – increasing RAM||Horizontally scalable – add more servers|
|Emphasizes on ACID properties (Atomicity, Consistency, Isolation and Durability)||Emphasizes on CAP theorem (Consistency, Availability and Partition tolerance)|
MongoDB Documents also align with the structure of objects in modern programming languages, as they are a form of JSON. This makes it easy for developers to map the data used in the application to its associated document in the database. While in SQL Database, creating a table with columns mapped to the attributes of an object in programming language, appears a little tedious.