Image Courtesy : mongotips.com

All of us are pretty familiar with the relational database systems, their capability, pros and cons, and how to use the relational databases. But nowadays the new technology which is buzzing around in the field of software development is the NoSQL databases. As the name suggests the NoSQL databases have nothing to do with the traditional relational databases but is a step further in the development ladder. In our previous Blog we dived deep into NoSQL Database. In this blog we will discuss a popular NoSQL Database which has created a huge impact in the world of databases called MongoDB.

MongoDB is an open source NoSQL document oriented database which has its name derived from a word Humongous which means huge, as its name the applicability of mongoDB is also vast. Some of the basic features are that it provides high performance, high availability and automatic scaling. MongoDB is an ideal database where the amount of data is huge and we can avail the functionality of indexing in order to retrieve data faster. The records are represented as a document in mongoDB. The document is a JSON like document which is referred as BSON.

Structure of a MongoDB Database Document:

{

“_id”: ObjectId(“52e9e30cc7fd0981254f1a76”),

“avatar”: “default_spot_image.jpg”,

“location”: {

“city”: “Pune”,

“state”: null

}

}

The document is composed of fields and its value; these values can further contain an array of values which is referred to as an embedded document. The Embedded document helps in reducing the complexity of joins, an issue which was earlier associated with the traditional relational database. Inception of mongoDB has made the life of a developer easier as now they don’t have to waste their precious time in figuring out the query to be used in order to retrieve data from multiple tables having relations between them.

[Take a Deep Dive into the Different Types of NoSQL Datastores]

 

Some Features of a MongoDB Database:

– Document Oriented Storage

– Full Index Support

– Replication & High Availability

– Auto-Sharding

– Querying

– Good Support

 

MongoDB on Amazon EC2

The good thing with mongoDB is that it can be easily deployed on one of the prime cloud infrastructure provider in the market Amazon Web Services. There are two ways in which you can deploy mongoDB on AWS:

  1. Manually deploy mongoDB on EC2.

  2. Launch an instance with available mongoDB AMI’s on AWS marketplace.

Manually mongoDB can be installed on an EC2 instance using yum command which I will be discussing in the future blogs.

In AWS marketplace there are three AMI’s which are officially maintained on AWS marketplace are as follows:

  1. MongoDB 2.4 with 1000 IOPS

  2. MongoDB 2.4 with 2000 IOPS

  3. MongoDB 2.4 with 4000 IOPS

 

MongoDB application using YII Framework – What I found out about MongoDB

MongoDB has a huge technical support available. It has drivers and client libraries available on all the popular languages used for development purpose nowadays. I recently had a chance to explore mongoDB for a Product Development Project which had the requirement of using mongoDB as a backend database.

This Application is a lifestyle application which has a web as well as mobile version for both android and iOS platform. The application primarily allows business houses to create new deals which are related to their business and the users who are following the business on the App can see those deals, share them, like and also comment on deals just like a social app. This was just a brief overview of what the application does. As you know social apps generate huge amounts of data, so in order to reduce the complexity of storing that data in different tables and querying them and retrieving data based on relation we used mongoDB as our database for application because the data for a single entity can be maintained in a single document and all the other relations are stored in the form of embedded documents which helps the application in retrieving data from the database faster and improves the overall performance of the application.

[What are No SQL Databases – Here is a Detailed Overview]

 

How MongoDB helped us in our Mobile Application Backend

In order to provide a seamless user experience in a mobile application it is necessary to have a quick response mechanism between the mobile device and back end web services. Web services accept input from mobile devices and then processes the request to get data by querying inside the database. However, if these processes take more time then it will result in high latency which is an obstacle for a seamless user experience. So to avoid that we used mongoDB which has an indexing feature that helps in faster data retrieval, apart from that the mongoDB document oriented json like structure is an added advantage as it helps in reducing the complexity of making request and response by having json object as parameter.

If it would have been a relational database then it would have been more difficult to parse the json and enter records based on the relation between the tables. MongoDB easily stores json objects in its document based structure. Moreover the apple passbook specification is strictly json, so there was a need to have a web service with json as primary data exchange format. As mongoDB is schema less so we can define our own schema in the application and can change as and when required which will not have any effect on previously stored data.

I would like to conclude by saying that MongoDB is a great bet when it comes to using a database for storing large amount of data. It can be used easily and gels with all the popular programming languages comfortably as it has support for all the major programming languages. Using this schema less database will help you in improving performance & optimize your application.

Tags: , ,