What is MongoDB
MongoDB is a general purpose database which is fast and scalable, it is used for a variety of use cases and a popular open-source document-oriented database developed by MongoDB Inc. The most common use cases for MongoDB include Single View, Internet of Things, Mobile, Real-Time Analytics, Personalization, Catalog, and Content Management. With the addition of multi-document transactions, it is even easier for you to address a complete range of use cases with MongoDB
Why MongoDB
MongoDB is built on a distributed systems architecture, rather than a monolithic, single node design. As a result, MongoDB offers out-of-the-box scale-out and data localization with automatic sharding, and replica sets to maintain always-on availability. Business logic is distributed across Client Applications and eliminates centralized need for Stored Procedures in the backend system. Saying that, special skilled resources on SQL based environment is not required any more and the same can be covered by the Application developers who are more close to the business. MongoDB also ensures,
- High performance
- High availability — Replication
- High scalability – Sharding
- Dynamic — No rigid schema
- Geospatial support
- Easy Integration with BigData Hadoop
- Powerful Document-based query language
Why Organizations choose MongoDB
Organizations choose MongoDB because it enables them to build applications faster, handle highly diverse data types, and manage applications more efficiently at scale. Development is simplified as MongoDB documents map naturally to modern, object-oriented programming languages. Using MongoDB removes the complex object-relational mapping (ORM) layer that translates objects in code to relational tables. MongoDB’s flexible data model also means that your database schema can evolve with business requirements
As organizations are more on building their infrastructure over cloud the fact, MongoDB is built for the cloud. Its native scale-out architecture, enabled by ‘sharding,’ aligns well with the horizontal scaling and agility afforded by cloud computing. MongoDB can also be scaled within and across multiple distributed data centers, providing new levels of availability and scalability which is previously unachievable with relational databases. As your deployments grow in terms of data volume and throughput, MongoDB scales easily with no downtime, and without changing your application. In contrast, to achieve scale with relational databases often requires significant, custom engineering work
Why developer choose MongoDB
- From Rigid Tables to Flexible and Dynamic BSON Documents
- Documents represent data in the same way that applications do. This makes it much simpler and faster for developers to model how data in the application will map to data stored in the database
- Documents make applications fast - with data for an entity stored in a single document, rather than spread across multiple relational tables, the database only needs to read and write to a single place. Having all the data for an object in one place also makes it easier for developers to understand and optimize query performance
Benefits over RDBMS
The relational database has been the foundation of enterprise data management for over thirty years. But the way we build and run applications today, coupled with unrelenting growth in new data sources and user loads are pushing relational databases beyond their limits. This can inhibit business agility, limit scalability, and strain budgets, compelling more and more organizations to migrate to alternatives. The RDBMS optimizes data storage efficiency (as it was conceived at a time when storage was the most expensive component of the system. But the MongoDB’s document model is optimized for how the application accesses data (as performance, developer time, and speed to market are now more important than storage volumes)
The Schema evaluation and impact on Schema design - In the world of SQL, the developers and DBA working on a new development project using a RDBMS must first start specifying the database schema before the code is written. MongoDB enables developers evolve the schema through an iterative and agile nature
The out of the box benefit of NoSQL database over RDBMS is the full text search feature. MongoDB provides a specialized index for text search that uses advanced, language-specific linguistic rules for stemming, tokenization and stop words. Queries that use the text search index return documents in relevance order. Each collection may have at most one text index but it may include multiple fields
Benefits over other NoSQL Databases
- Multi ACID transactions supported from 4.0 which is unique from other NoSQL databases
- The Aggregation framework is extensive to match almost all the SQL features which not most of the NoSQL gives
- Native, idiomatic drivers are provided for 10+ languages – and the community has built dozen
- BI connectors - MongoDB can be easily explored with industry-standard SQL-based BI and analytics platforms
- MongoDB Charts is a new tool that enables you to quickly and easily create and share visualizations of your MongoDB data
Considerations when migrating from RDBMS to MongoDB
Importance of de-normalizing data - as the collections are normalized the number of joins when you query increases. One biggest benefit of MongDB over RDBMS is less number of reads from the disk/store. Means, reducing number of relational joins reduces the no of reads to the physical store exponentially and which intern provides a high performance
In other side, there are examples where normalizing data can be beneficial, especially when data from multiple sources needs to be blended for analysis – this can be done using the $lookup
Schema modeling considerations
- Applications data access pattern
- Life-cycle of data
- Growth rate of documents
Embedding vs Referencing
- Embedding used in 1:1 or 1:m relationship where many objects always used in the context of the parent document, or the other way there is not much relevance for the child document if the parent is deleted
- Referencing is more of normalization m:1 or m:m relationships, if the objects are referenced from different sources
Indexes in MongoDB largely correspond to indexes in a relational database. MongoDB uses B-Tree indexes, and natively supports secondary indexes. As such, it will be immediately familiar to those coming from a SQL background
What more MongoDB offers
Other than what is been discussed above, MongoDB as an enterprise offers lot of services and offerings which an organization or an individual can get benefited. I have listed them below for reference and will cover them in-detail in future
MongoDB Atlas: Database as a Service For MongoDB, this service, offered in the public cloud. Atlas enables customers to deploy, operate, and scale MongoDB databases on AWS, Azure, or GCP in just a few clicks or programmatic API calls. MongoDB Atlas is available through a pay-as-you-go model and billed on an hourly basis. It’s easy to get started.
MongoDB Stitch: The MongoDB Stitch serverless platform facilitates application development with simple, secure access to data and services from the client – getting your apps to market faster while reducing operational costs. This provide four services, Stitch QueryAnywhere, Stitch Functions, Stitch Triggers and Stitch Mobile Sync.
MongoDB Mobile: MongoDB Mobile lets you store data where you need it, from IoT, iOS, and Android mobile devices to your backend – using a single database and query language
MongoDB Compass: Tool which provides the ability to visualize explain plans, presenting key information on how a query performed
MongoDB Cloud Manager: is a cloud-based tool that helps you manage MongoDB on your own infrastructure. With automated provisioning, fine-grained monitoring, and continuous backups, you get a full management suite that reduces operational overhead, while maintaining full control over your databases.
MongoDB Consulting: MongoDB Consulting packages get you to production faster, help you tune performance in production, help you scale, and free you up to focus on your next release
MongoDB Training: MongoDB Training helps you become a MongoDB expert, from design to operating mission-critical systems at scale. Whether you’re a developer, DBA, or architect, we can make you better at MongoDB
MongoDB Enterprise: MongoDB Enterprise Advanced is the best way to run MongoDB in your data center. It’s a finely-tuned package of advanced software, support, certifications, and other services designed for the way you do business