Sunday, August 31, 2014

Mongo DB

Mongo DB is a No-SQL database technology that is growing in popularity. Generally used in large intense transactional applications such as applications for telcos, national distributors, global e-commerce solutions, social media etc. Mongo DB presents a number of clear advantages versus the traditional tabular SQL type of databases.

Written in C++ on a high performance engine, Mongo organizes its data in documents and data collections rather than records. A JSON/BSON type of syntax is used to describe the data model. The schema is dynamic and the query language is object oriented.

Here is an example of how to define a one-to-many relationship in Mongo DB (I borrowed this example from the online docs @ mongodb.org). In a traditional SQL data modeling world, this would be equivalent with defining a record for a library card owner with name and address (in this case the owner has two addresses registered with the system).

{
   _id: "joe",
   name: "Joe Bookreader",
   addresses: [
                {
                  street: "123 Fake Street",
                  city: "Faketon",
                  state: "MA",
                  zip: "12345"
                },
                {
                  street: "1 Some Other Street",
                  city: "Boston",
                  state: "MA",
                  zip: "12345"
                }
              ]
 }

Mongo DB has very simple and powerful query/retrieve and inserts type of mechanisms. Here is for example how you retrieve from an inventory collection all the documents of a certain type. Here we go again from the online docs of mongodb.org

db.inventory.find ( { type: "novels" } )

Some of the advantages of using Mongo DB vs. other types of SQL databases are:

- higher performance on volumes of read/write operations
- built-in high availability, load balancing and fail over mechanisms
- better scalability
- built-in mechanisms to present location based data
- lower cost of ownership and maintenance
- better mechanisms to flexibly modify the database schema on the fly
- natural mechanisms to implement agile development practices

The concept of No-SQL databases is not necessarily new. By writing C++ code, we had been implementing document oriented databases since the mid '90s. But the latest developments (especially what happened in No-SQL databases between 2009 and now) and the scale of some applications are very interesting.

Mongo DB is used these days by companies like E-Bay, Forbes, Microsoft, Cisco and Craigslist and with the ever increasing need of dynamic volumes of data manipulation, it will more likely continue to grow.

Mongo stands for Humongous! But you don't have to be huge to start using it. It is actually a great idea to design with growth, performance upkeep, scalability and agility in mind.

Make it a great day!

Adrian Corbuleanu
Miami Beach, FL