How to use MongoDB

5th Oct 2016

Web developersThis article is the first in a 2-part blog series about MongoDBPart 1: [you are here] How to use MongoDBPart 2: Why NOT to use MongoDB Since 2009 there is a new kid on the Database block: MongoDB[caption id="attachment_3464" align="alignnone" width="432"]Screen Shot 2015-05-29 at 9.55.22 am More and more people are interested in MongoDB[/caption]According to Wikipedia, MongoBD is the number 4 database system at the moment.Want to know what the experts say about MongoDB? Download these answers to the most asked questions about MongoDB 
MongoDB (from humongous) is a cross-platform document-oriented database. Classified as a NoSQL database, MongoDB eschews the traditional table-based relational database structure in favour of JSON-like documents with dynamic schemas (MongoDB calls the format BSON), making the integration of data in certain types of applications easier and faster. Released under a combination of the GNU Affero General Public License and the Apache License, MongoDB is free and open-source software. https://en.wikipedia.org/wiki/MongoDB
When you look at the blue trend line above it certainly seems that MongoDB is rapidly becoming popular as a Database system. However, looks can deceive sometimes (and it also shows how easy it is to skew data). Check out the search volume of MongoDB (blue) against MySQL (red) in the graph below.[caption id="attachment_3463" align="alignnone" width="299"]Trendline for Google search Trendline for Google search (blue = MongoDB red=MySQL)[/caption]My SQL is definitely still more popular than MongoDB, but the trendline is dropping... while MongoDB's trendline is climbing. On average there are 201,000 searches for MongoDB - a stark contrast with only 74,000 searches for NoSQL (according to Google's Adwords keyword planning tool) Monthly searches globally for MongoDB:Screen Shot 2015-05-29 at 10.26.08 am Check out what others are discovering about MongoDBMonthly searches globally for Nosql:Screen Shot 2015-05-29 at 10.27.12 am So MongoDB is definitely nothing to be sneezed at... But we still have the graph on the top with the comparison between MYSQL and MongoDB. How does that translate in monthly searches? You guessed it.... Screen Shot 2015-05-29 at 10.26.28 am With MongoDB being a serious contender in the Database space, the question is: how to use MongoDB? Looking at Quora, it seems that the largest users of MongoDB are companies like Foursquare and SourceForge. It's all about storing documents
Foursquare is using MongoDB. Harry Heymann says in the comments on Jul 8, 2010: "Foursquare currently has 6 MongoDB instances in production (3 masters, and 3 slaves). We expect this to increase significantly over time. I can say however that we're very pleased with MongoDB thusfar." According to their presentation from MongoSF [9], Bit.ly are using MongoDB to store and serve user history. Bit.ly currently see "~1.25B shortens per month ( 1K/sec peak )", which are logged in MongoDB. SourceForge.net is using MongoDB to store all of their data [10], and it has allowed them to "serve all of the project pages on SourceForge.net without any page level caching."
And I really like Steve's answer to the question "What are the main benefits of MongoDB for WebApplications" --> after all Mongo DB is a tool, like there are many more. Understand what the tool can do and choose wisely.  
Steve Klabnik, I've been programming since I was 7.A couple of things:* It's a really nice bridge between SQL and NoSQL. Mongo, especially when using an ORM, has a lot of features that are similar to relational databases, and so it's an easy way to get your feet wet with document stores.* It maps really nicely to most dynamic languages. Since it understands arrays and hashes natively, it almost feels like an object database when used with Ruby.* MapReduce has a nice interface. Their javascript implementation is much cleaner than other NoSQL stores.* It's freaking fast.* Atomic operations let you do some things that would need a transaction in a relational database.* Geospatial queries are built in. No more relying on third parties for this stuff, unless you have really specific needs, or need to be ultra-accurate.