Part1 – Learning & Sharing Series – MongoDB -java

This document is to share some info collected from web and few features i tried out.

NOSQL

The main principle being ‘RDBMS for not all kind of works’. As an article author quotes ‘it has to be NOT ONLY SQL rather than NO to SQL’.

So mainly it is giving up some parts of RDDMS for scaling-speed- flexibility-easiness.

Please read this .Informative.

http://www.rackspacecloud.com/blog/2009/11/09/nosql-ecosystem/

What I like about the NoSQL crowd.- Good curtain raiser

http://blog.postmaster.gr/2009/11/05/what-i-like-about-the-nosql-crowd/

A very good discussion at

http://stackoverflow.com/questions/1476295/when-to-use-mongodb-or-other-document-oriented-database-systems

NOSQL storages have 4 formats. 1. Document oriented ( for complex data designs) 2. Key value pairs 3. Column -oriented 4. Graph oriented

My understanding is this.

1. Scalability as TB has become common factor even in home servers

2. Neccessity of easy Real time data mining and reports

3. SQL or schema / relational integrity is not required in many designs and its a overhead.

4. RAM has seen drastic downfall in price .4 GB costs around $100

5. We need ripples once in 2 years like RubyonRails, NOSQL, Virtualization, cloud computing

6. Changing data dimensions because of dynamic business model. This is the real kill .Google Buzz is a new BM for Google.

7. Might be a perfect suit for Data warehouse BII systems where 3NF is the design strategy

MongoDB

One of the best web clipping

“Rather than rows in a table, Mongo stores documents in collections.

Documents are (slightly enhanced) JSON objects, so you can stash much more complex structured data in a single document than you can store in a table row.

Natural data structures: arrays, objects, dictionaries. Data modeling becomes a much more natural process.”

I . Impressed by this link

http://eu.techcrunch.com//2009/09/08/silentale-lets-you-archive-and-search-your-every-conversation/

II More impressed by this link

http://www.businessinsider.com/how-we-use-mongodb-2009-11

III Caught in glaze of the NOSQL movement ( though none of the  systems i used in last 5 years scaled more than 3 nodes)  , had a goal of  get  to know about one of the NOSQL DB’s.

Though used memcache and java based in memory libraries in previous projects , this is the first time to try a complete NOSQL persistentDB solution.

Deciding between CouchDB and MongoDB to read about was a tougher decision , though both have good list of production deployments by big firms.Selected MongoDB to read about as couchDB is in alpha

http://stackoverflow.com/questions/895762/mongodb-or-couchdb-fit-for-production

http://discuss.joelonsoftware.com/default.asp?biz.5.727383.8

http://www.linkedin.com/answers/technology/information-technology/databases/TCH_ITS_DBS/633444-24053574

Where Can be used:

There is a clear explanation of use cases given in the Mongodb official website

http://www.mongodb.org/display/DOCS/Use+Cases

For more Business cases view the production deployments http://www.mongodb.org/display/DOCS/Production+Deployments

esp. this is interesting http://www.businessinsider.com/how-we-use-mongodb-2009-11

[One of the websites cofounder seems to a VC for MongoDB ]

Additional Info about MongoDB

1. Document store model not table-rows-columns. So nested values is possible with eachkeys. Querying will be effective and precise. Uses JSON like Schema.

2. Schemaless- Referential integrity- Joins less.So refactoring and modification is quite easy. For example adding a column to a existing table

http://blog.mongodb.org/post/119945109/why-schemaless

3. Currently Win 32/64 ,Linux 32/64, OS-x 32/64 bit, Unix(*NIX only) versions are available

4. Clusterable. Supports Master – Slave, Replica Pairs model.

5. Supports Shard. (Horizontal Partioning)   .Till in Alpha .More details at

http://www.mongodb.org/display/DOCS/Sharding+Introduction

6.Claims better performance than Mysql.

MongoDB performed more than 2X better than MySQL

http://obvioushints.blogspot.com/2009/07/benchmarking-mongodb-vs-mysql.html

7.Has sets of good features like

  • ”updates-in-place’  using  the Mongo  mondifiers- upsert , $inc .
  • Capped Collections – Fixed size collections having age out based on insert order.Will be handy in logging & Sorting
  • Enhanced Queries

8.Uses JSON for its query and display – BSON binary based JSON for storing documents for efficiency.

9. ACID in supported for only a single document and cannot span multiples. So not for a banking/Financial application

10. For 64 bit machines the data volume is not limited and on 32 Bit system the map file size can be up to a max of 2 GB

11.Online shell  is available at http://try.mongodb.org/

12. Commercial service providers are currently very limited.

The photon PHP based framework is interesting

http://www.mongodb.org/display/DOCS/MongoDB+Commercial+Services+Providers

13. Drivers are available for java.php ,C#,Ruby,C++,Perl

14 Has import  – from json string formatted document  &  export options – in csv

15. MongoDB does not support transactional locking and the primary reasons said to be to avoid deadlocks , distributed locks and to enhance real time   performance t has other means of support using techniques – ”Update if Current’ & ‘Insert if Not Present’

Simple 3 tries using MongoDB ( Windows) – java

1. General CRUD using java

2. Image persistence and retrieval

3. Large objects saving and retrieving using GridFS

Details about java -MongoDB is available here.

http://www.mongodb.org/display/DOCS/Java+Language+Center

Windows installation is just unzipping the file

[ !Note create a directory \data\db in the same drive where Mongodb resides]

Files in the bin directory

Server Console

General CRUD using java

Insertion

Insert Result

Searching

Search Results

Update

Result after updating

Delete

Result

Image persistence and retrieval

Image Retrieval

Result

Native storage of BSON supports only 4 MB it seems and 32 bit it is 2 MB i believe as I got an exception below.

Related documentation and info available at http://www.mongodb.org/display/DOCS/GridFS

GridFS Insertion

GridFS – Retrieval

Links that may provide more information

http://www.linux-mag.com/cache/7530/1.html

http://www.phpclasses.org/blog/post/118-Developing-scalable-PHP-applications-using-MongoDB.html

http://howsoftwareisbuilt.com/2010/02/13/interview-with-eliot-horowitz-cto-of-10gen-mongodb/

http://www.paolocorti.net/2009/12/06/using-mongodb-to-store-geographic-data/

About these ads