MongoDB – making life simpler!

When I heard about MongoDB from a friend, I had no clue what it had in store for me. For a programmer like me, who works with jQuery a LOT, MongoDB fit right into one part of my jigsaw puzzle 🙂 Let me decode the Greek and Latin I just spoke.

jQuery is a UI development language that is built using Javascript libraries.It is an easy way to develop UI such that there is least difference in cross browser functionality. If Javascript were breadcrumbs, jQuery is crumbs rolled into balls.

Objects in Javascript are represented using JSON. JSON stands for Javascript Object Notation. They are lightweight, easy to decode. The look like this in their easiest form:

{ “name”:”Pearl”,

“age:24}

Say one day you wake up and decide to build a webapp that captures data about people and stores it in a database. And you need to do it fast. MongoDB would be the perfect choice. You create your UI using html and jquery, you can use enhanced engines like Node.js along with jQuery, or jsp and servlets(would add some overhead) to write your logic that lies between your database and UI, and mongoDB to store the data just the way it gets passed down from the UI in JSON format! Isnt that cool? A quick easy solution.

MongoDB is also easily scalable too.it is less restrictive than relational database. If RDBMS is ur strict teacher , MongoDB is ur fun aunt. Of course they are not replaceable, but for a large set of purposes mongoDB would serve just fine.

For starters – MongoDB has no joins, no transactions persay, and no sql! The data is stored in ‘collections’ which are composed of ‘documents’ which are nothing but – JSON objects as above! So what we SQLers knew as a table, is now a collection. What we knew as rows, is now a document. Of course, each item in the row constitutes separate  columns.

So a collection ‘friends’ may look like this:

{“_id”:”xxxxxxxxxxxxxxxx”,”name”:”DS”, “category”:”best”,”profession”:”Data warehousing”}

{“_id”:”yyyyyyyyyyy”,”name”:”SM”, “category”:”best”,”””profession”:”Telecom”,”hobbies”:[“acting”,”reading”]}

{“_id”:”zzzzzzzzz”,”name”:”AS”, “category”:”best”,”profession”:”Application development”, “interests”:[“music”]}

MongoDB has no schema. The number of fields in each document may vary, even while being part of same collection. The _id field that you see is special – it is present in every document and is unique, added automatically. It can be manipulated, but carefully.

MongoDB has a lot to offer – it has indexing capabilities, great provisions for querying, sharding ( that allows for high levels of scalability), utilities like GridFS that allow you to store files of any size in MongoDB .. and many more that I would love to write about in the coming posts.

P.S. 10gen are the creators of MongoDB and have many amazing online free trainings related to MongoDB that you can take advantage of if you’d like.

Beginning to Flex!

So everyone has heard of Flash – yeah, the Adobe one(not Justice League!). That is now under the Apache shelter. That bore the brunt of Steve Jobs’ decision to not support it on Apple products.  That will definitely feed and feed from Bill Gates coffers as long as it remains hot.

I recently attended an introductory training on Developing Rich Internet Applications using Flex 4. Flex is actually quite impressive – the maturity of the language contributes a great deal to the ease of programming with it – and the richness of the UI it can deliver, on demand. Yes, HTML5 is a definite competitor, but it will be a while before it catches up, and wonder where Flash will be then. Again, the space of operation, and hence competition, is varied for most part, but HTML5 is catching up with the magic that Flex provides, and cross-platform(including iOS) at that.

But Flex is some really good technology that I’d like to talk about. It reminded me of mixture – not Haldirams’ All in One, but something a little more predictable like the Khatta Meetha, say. (to be understood by Haldirams’ snack fans only :))  So the two main ingredients of this mixture would be – MXML and ActionScript. MXML(Multimedia XML) is used to describe the UI, while ActionScript houses the business logic.

So you could describe the UI with MXML, and organise your business logic into ActionScript classes. (using Adobe Flash Builder, which is licensed, but has a 60 day trial – and allows drag/drop of UI controls like buttons, labels, panels etc and generates the code which is very helpful when you are a beginner). On compiling, the MXML pulls in the related ActionScript classes, (along with image files, and swc artifacts – which are components – if any) and compiles into this shippable piece(artifact) called swf(swiff, is how it is widely pronounced) which is understood by the Flash Player.The swf file could then be embedded into an html page and viola! your flash application is ready!

flex1

There’s a lot more to Flex than just this – maybe I will talk more about it in my coming posts as I discover it. It does fall short when it comes to SEO friendliness though. But the world of Flex is still a very fascinating one, worth exploring.