The blog will be covering those rare possibilities which can hold you back from choosing MongoDB as your NoSQL database. However, you will also find some really good reasons why you should go for MongoDB! Let's get through the suspense already and quickly brush through the pros and cons of building your application using MongoDB.
In the world of software application development, you no longer have to choose RDBMSes while you are starting a new project. To offer a more persistent and scalable approach, number of products which are generally referred as 'NoSQL's were created. Some of these products offer scalability and better read/write performance while others focus on representing the data more conveniently.
Quick Highlights of MongoDB:
MongoDB integrates within most diverse third-party ecosystem of libraries and frameworks.
MongoDB has flexible schema with ad hoc querying and low admin overhead.
MongoDB with excellent documentation holds within client libraries in all major programming languages.
MongoDB is faster and more scalable than other NoSQL databases.
Reasons to Choose MongoDB
2. Horizontal Scalability and High Availability: The database can be scaled horizontally smartly. Database scalability is handled via sharding which is pretty unique in its own way . Using MongoDB you can build a clustered topology with replication and sharding. To increase availability and consistency, MongoDB can replicate the data as well as create replica set. This happens because replication process provides consistent-read-scaling, sharding facilitates read-and-write operations, and the database, while still coming out with consistent values, handles replica operation failures intelligently.
3. Location Based Query Feature: MongoDB is a great choice if you have to develop an app that has location based features like location tracking, location based event tracking etc. MongoDB is among the only NoSQL databases with geo-spatial features.
4. Comprehensive Querying and Aggregation Framework: MongoDB gives you powerful querying facility which takes advantage of suitable indexes if you have created any, and allows you to query nested/embedded objects and arrays. MongoDB performs great under pressure especially when talking in terms of handling of ad hoc queries which are updated in real time. Aggregation Framework is a new mechanism which is specifically devised for queries, It requires any of MAX, AVG or GROUP BY from SQL. This framework allows you to run some ad-hoc aggregation queries without the need to write cumbersome Map-Reduce scripts.
5. Intuitive architecture: MongoDB has only a single master per replica compared to peer-to-peer architectures which is quite clumsy because of concurrent writes / write conflicts.
To Be or Not to Be?
We know that MongoDB is magnificent. It is great for projects that require handling of huge databases. This database is best suited for developing blogging platforms, e-commerce platforms, metadata storage and location based applications. But still one should think before considering it and let’s have a look when MongoDB can be a hitch for you:
You may end up wasting lot of time in running large and complex Map/Reduce jobs.
You would require JOINs or have to plan to use the “SUM” operation a lot of times.
You will be bothered for a lot of images or large pieces of binary data.
You may require a Queuing system.
Wrapping It up, but First Pitting It Against CouchDB
If you are ready to take up these challenges you should choose MongoDB as your NoSQL database. Here let’s look at some minor and major choices which developers must make while choosing between CouchDB and MongoDB.
1. If you are planning to have a mobile component, or if you need your desktop users to work offline and then synchronize their work to a server you must choose CouchDB.
2. If you want your code to run only on the server side then go with MongoDB
3. For Availability and Partition Tolerance choose MongoDB.
4. For Consistency and Partition Tolerance choose CouchDB.
5. If you need dynamic queries and prefer defining indexes (and not map/reduce functions), choose MongoDB.
6. For occasionally changing data on which pre-defined queries are to be run, choose CouchDB.
So basically to summarize this, for replicating to mobile and desktop services you need CouchDB and if you are looking for performance, community and tooling then MongoDB would be a smart choice.
That's all for now. Keep reading, keep coding!