Hello friend and welcome to the MongoDB overview 🙂 In this introduction, we will cover everything from its genesis, benefits, and drawbacks to real-life use cases.
Please keep in mind this is the 4th blog post in a series about the most popular databases, and you can find the previous articles right here:
- Discover the Power of PostgreSQL: A Comprehensive Introduction
- MySQL Essentials: A Fast-Paced Introduction
- Redis Database Explained
Please sit back, relax, and get ready to discover why MongoDB is taking the world by storm.
If you enjoy whiteboard animations, then right here you can find a video version of this article:
If you find this content useful, please leave a subscription 😉
As the first thing in our MongoDB overview, let’s take a second to learn more about its genesis.
MongoDB’s history starts in October 2007 in a company called 10gen. The founders were looking for a scalable solution, capable of dealing with a high volume in their internal project. (Un)Fortunately, at that time relational databases were not well-suited to handle the kind of semi-structured data they needed. As a result, they decided to build their own NoSQL database with the scalability and large amounts of unstructured data handling in mind.
Almost two years later, in February 2009, Mongo was released as an open-source project. Since then, it quickly gained popularity among developers and businesses who were looking for more flexible solutions. Of course, compared to relational databases.
In 2013, 10gen changed its name to MongoDB, reflecting the growing popularity of the database.
Today, Mongo is widely used by organizations of all sizes, across various industries. Not to mention, we can choose not only between the Community and Enterprise editions but also a cloud-based database as a service called MongoDB Atlas.
MongoDB is written in C++ and uses a binary form of JSON called BSON (Binary JSON) to store data. These documents can have fields that hold values of different types, such as:
- and even nested documents.
Just like rows in relational databases are combined together in tables, Mongo documents are grouped in collections. Of course, with one, important difference: each document can have a different structure.
When it comes to scalability, MongoDB uses a sharding architecture to scale horizontally. Sharding, in simple words, allows a Mongo cluster to store more data than can fit on a single server by automatically partitioning the data across multiple machines. In such a situation, each shard contains a subset of the data and the query will be directed to the appropriate shard based on the query.
Of course, MongoDB also provides additional advanced features, like complex query language, indexing, a full-text search, and a replica set mechanism.
So, with all of that covered, we can take a while to learn a couple of MongoDB advantages:
- Firstly, flexibility. As I already mentioned in this MongoDB overview, documents within a collection do not need to have the same structure, or fields, unlike traditional relational databases. Mongo allows for a flexible schema and can be a great choice for some projects.
- Moreover, document-oriented storage makes it relatively easy to work with MongoDB using popular programming languages that have built-in support for JSON.
- Thirdly, great performance. Mongo is designed for high performance and can handle large amounts of data.
- Additionally, scalability and high availability. MongoDB can be easily scaled and comes with built-in support for automatic failover and replication.
- And finally- it’s easy to use. Mongo provides a simple command-line interface and it is easily integrated with a lot of programming languages and tools.
Of course, I must list a couple of disadvantages in this MongoDB introduction, as well:
- Firstly, Mongo uses a MongoDB Query Language (MQL). And although it has the same syntax as documents (which makes it really intuitive), it’s nothing universal and we have to learn it in order to work with the database. This is not the case, for example when working with SQL.
- Moreover, MongoDB does not support joins, which we know from relational databases. And although combining documents, or collections together is still doable, it might be a bit tricky task.
- Additionally, documents cannot exceed 16MB.
- And lastly- data redundancy. Due to the lack of joins, we oftentimes duplicate data across the documents, which may lead to harder maintenance.
Overview Of MongoDB Use Cases
With all of that said, let’s figure out when Mongo can be a good choice:
- And as the first one- content management. It can be used to store and manage large amounts of structured and unstructured content, thanks to its flexibility.
- Secondly, the Internet of Things. MongoDB is a popular choice for storing and processing large amounts of data generated by IoT devices. Mongo is not only great at dealing with large amounts of data but also can handle semi-structured and unstructured data sent by IoT devices.
- Additionally- e-commerce and recommendation systems. A flexible schema allows for easy storage of various types of product data, like prices, descriptions, etc. Moreover, MongoDB support for complex queries and aggregations can help easily create search engines and recommendation systems
- And as the last one, a bit more general- real-time applications. MongoDB’s low latency and high performance make it a great choice for any real-time application, like social media for instance.
Which Companies Use MongoDB?
And as the last thing in our MongoDB overview, let’s figure out which companies are using it in their technology stack.
eBay uses MongoDB to store information on items for sale and to power the search functionality. Additionally, Mongo is used to store data about users’ browsing and buying history, which is then used for personalization purposes.
Another great example is Vodafone, which uses it for IoT, new 5G innovations, and cloud-native apps.
Moreover, Uber makes use of Mongo to store and manage data related to its operations, such as information on drivers, riders, and rides.
MongoDB Overview – Summary
And that’s all for this MongoDB overview. I hope that you enjoyed this introduction and if that’s the case, then please let me know in the comments 🙂
Of course, if you’d like to expand your knowledge of MongoDB in practice, then check out my other resources:
- REST API With Micronaut, Kotlin, and MongoDB Course
- A Guide To Ktor With MongoDB
- Spring Boot MongoDB REST API CRUD with Kotlin
Thank you and see you in the next articles!