When should you use MongoDB? When shouldn’t you use MongoDB? What are the pros and cons of this database? Let’s break it down.
MongoDB is NOT For Me!
If you need a relational database, meaning your data can be structured into categories of information that are linked to one another, then MongoDB is not for you. Think of a class roster that has all of the student's names with their associated attendance, test scores, etc. In this model, the data itself is structured and it would make more sense to represent the data in a table rather than in a laundry list of items. Thus, this scenario would not benefit from using MongoDB.
MongoDB is For Me! (With Pros & Cons)
MongoDB is a non-relational database, meaning the data are fairly unstructured and housed in long documents. When going with a non-relational database, the scope of your data is large, complex, and comes from many different inputs. Furthermore, one piece of information doesn't have to be related to another. Think of a messaging platform. This would be a non-relational database because it would be most easy to store all of the messages sent in a long document. It wouldn’t really be possible or intuitive to try to conform this type of data into an organized table.
The main benefit of MongoDB is that it is incredibly flexible. You aren’t bound to specific data structure limitations. If there is something you want to change, you just go ahead and make that change and it subsequently happens from there.
Looking at MongoDB specifically, it attracts many due to its high performance and strength in automated scalability. It is super easy to install and it typically uses JSON documents to store data. It’s a popular choice for a reason.
- The database is highly flexible
- It can be distributed amongst multiple databases
- It is really fast and great for scalability
- Is easy to set up and implement
- The database takes up a ton of memory
- It has a document size limit of 16 MB
- It has limitations of nesting to 100 levels
- There is a limit of 20,000 to your max connection number
Take your pick. Does MongoDB sound like it is for you? Do you still have questions about it? Feel free to reach out to us at firstname.lastname@example.org