Monday, December 12, 2011

MongoDB | Document Oriented, No SQL open source database - Part 1

OBJECTS. It is all about dealing with objects. That is, storing them, retrieving them back, updating them PLUS encoding, efficient indexing, replica managing etc. Typical object can have its own as well as inherited feature sets. These can be considered as key value pairs like below.

{"username":"bob","address":{"street":"123 Main Street","city":"Springfield","state":"NY"}}

Above is an example of simple nested JSON object. When remote method invocation or
inter process communication happens, by using this kind of mechanism to send data
can be more convenient. When received, by querying, storing data back in SQL
databases is not needed if there exits a secure, storage effective document
oriented querying language. That is where MongoDB fits with BSON format. It is a cross language database system yet to come with more features. BSON helps to store JSON objects as binary objects which reduce size & increase indexing & retrieving performance.

In this post, a simple working scenario for successfully installing mongoDB
on Linux based operating system (basically on Ubuntu 10.10) will be discussed.

Installation1. Add MongoDB repository into Ubuntu assuming installed ubuntu version is 10.10Add below line any where of source.list file.

3. Do sudo apt-get install mongodb-stable to install mongoDB into your Ubuntu.If that didnt work, use just sudo apt-get install mongodb instead of -stableTest by run command mongo and you will get MongoDB shell versionNow we have to configure mongoDB with PHP Driver so that you can interact with mongoDB programetically via server-side scripting language.4. Configure MongoDB PHP DriverBefore configure mongoDB PHP driver, first need to have build-essential, php5-dev and php-pear.To install those:sudo apt-get install build-essential php5-dev php-pear**remember to tick on first two updates in software updates/updates in synaptic package manager. Otherwise system will not download all the packages needed & later steps will fail.