Why to Chose MongoDB over SQL

Posted by fcamuz on March 4, 2020

I was recently asked a question about MongoDB in an interview. The question was why MongoDB is preferred over SQL. I decided to write this blog about it.

SQL stands for Structured Query Language. Databases are categorized as SQL and NoSQL. NoSQL is simple the ones that are not SQL. MongoDB is in the NoSQL side. SQL is created by Microsoft years before the MongoDB created by MongoDB. MongoDB data base is widely used, and it performs mostly better than SQL database. There basically three main important features of MongoDB that makes it preferable.

1. Flexibility

2. Performance

3. Scalability

Flexibility

MongoDB is flexible database. The schema of the data allows to store multiple types of data. Collections do not enforce document structure.

This flexibility gives you data modeling choices to match your application and its performance requirements dynamically (pdf, audio, video). Therefore, it can dynamically modify the schema without downtime.

Performance

Unlike SQL, MongoDB execute fast even the number of queries increases. It takes more time to execute those queries. Various factors contribute to the high performance of MongoDB. It provides the embedding of documents. It avoids joins and provides indexing of data.

Scalability

As the consumption of data grows, MongoDB is adjusted. It handles this growing by horizontal scaling.

In conclusion MongoDB is a NoSQL database which is more advanced and capable of handling more data. SQL server is a database management system which is used to manage the relational database system. There are cases that one must use SQL over MongoDB such as relational databases but other times MongoDB outperforms SQL.