Part1 – Learning & Sharing Series – MongoDB -java
This document is to share some info collected from web and few features i tried out.
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.
What I like about the NoSQL crowd.- Good curtain raiser
A very good discussion at
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
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
II More impressed by this link
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
Where Can be used:
There is a clear explanation of use cases given in the Mongodb official website
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
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
6.Claims better performance than Mysql.
MongoDB performed more than 2X better than MySQL
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
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.
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
General CRUD using java
Result after updating
Image persistence and retrieval
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 – Retrieval
Links that may provide more information