My overview on MongoDB

Recently I have done a online MongoDB certification developer course with 10Gen. Prior this certification I haven’t never tried or really used a NoSQL database and after it I can say that I would really think twice if I would only use a relational database on a big project.

There is a big change of concept here, differently from a relational database with MongoDB you are willing to give up on relationship and see data in a object way. Let me see if I can explain this better.

In a relational database you would have a set of tables like:

Users 1 – n Addresses 1 – n AddressTypes

In MongoDB you would have a Json Object that would have all data from the user including (or not) the addresses and it’s types. What you store for a given object is completely up to you and if you really want to keep a relation between objects (split the user from the address object for example) you can, but you would have to do it programatically.

It’s a bit hard of a concept to understand at first glance, another reason why I did really enjoy the online course that 10Gen gave, but once you understand it is only natural that you start reconsidering a lot of the decisions you had made with a relational database. It is not only a case of performance, it can also be a case of how you scope your objects and data on the database in a way that you can not only gain performance but also keep the necessary data in a single object.

Consider a real state agency website for example, A lot of the data that relates to a house can be hold into one single object. It not only could be held but also it can shrink the size of data since not every single house does offer the same standards or assets.

Aside of the concept that MongoDB brings it also brings 5 great features that can bring advantages depending of the project that you are dealing with:

  • Aggregation Framework (or it’s complex queries method) that use a concept similar to the Linux pipeline
  • 2D / 3D Geo-find – instead of doing insane big queries with math in it to find a geo-location, MongoDB already comes with this feature
  • Data connectors. It already have a ton of good connectors that works with some of the big languages (like PHP) and frameworks
  • GRIDFS or Blob Sharding  – splits big chunks of images in several collections making it easier to save and gather the image
  • Server Sharding – It is almost ridiculous how  easy is to setup several servers with voting capabilities to handle your MongoDB data, replication, etc

At the moment I’m not entirely sure if I could re-do a whole project only using MongoDB, but I would, given the time and goals, really consider it. The big reason is that I love the concept of storing an object instead of data parts.

Consider the following, if you need to store a whole session on the database which would be the best way to do it: a simple JSON object. With json_encode and json_decode from PHP, for example, you can easily create an array with the whole data.  If you can consider do this with a relational database, why not use a NoSQL database like MongoDB.

If you still have your doubts about MongoDB or even NoSQL databases I would give a check on the online training and their documentation. You probably will find it really fun to work with it.

Today I can say that I understand why MongoDB is becoming more and more popular by the day.

About mcloide

Making things simpler, just check: View all posts by mcloide

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: