21
Dez
09

Get schema-free within minutes using MongoDB

As me, many software developers learned the relations view of database management system: Identifiy entities, develope a database schema, normalize it and map it to a real DBMS system. That’s fine. And for many application this approach is just fine.

For other types of application, this approach tends to make development complicated.

Suppose, you need to create a note taking application. The app should be able to take notes. A note should have a title, a text body and an arbitrary number of optional fields, a use may use to add small snippets of text. Hm, an arbitrary number of fields, which you don’t know up front? How would you implement them in your favorite DB system?

Create a new table, which keeps each single optional field? Probably too inefficient.
Serialize optional fields and drop them into a single attribute of a table? Hm, complicated. How would you manage search operations?

Without pointing towards a relational solution, I’d propose to use a non-relational DBMS system. Especially a schema-free DBMS.

Schema-free solutions

A schema-free DBMS is one, which allows to store any kind of data of any structure. You don’t need to define your DBs tables and attributes up-front. Simply create new attributes of as soon as you need a new attribute.

Think of a schema-free DBMS as one, which manages key-value coded tuples [XCode users: Key-Value coding comes to mind].

In case you’d like to have a look, your first Google hit might point you to CouchDB, which meanwhile is a project of the Apache foundation. CouchDB is an Erlang-based solution. Thus you not only need to download and install CouchDB, but an Erlang runtime too.

Recently I stumbled upon MongoDB, which comes as a no-dependencies solution. Download it and start mongod, the MongoDB server. That’s it. Finally, you might wish to download and install a MongoDB driver for your preferred language.

Yet, MongoDB doesn’t come with an AS3 binding. To get access to MongoDB from within your Flex/Air app, various ways exist. One might use MongoDB’s PHP-driver, add some AMFPHP magic and finally expose your MongoDB’s API to flex.

Resources

A recorded webinar by MongoDB’s parents
A MongoDB presentation held at the NOSQL conference 06/2009

PS: Actually, it is kind of funny, how IBM developed SQL: The original intention was to create a tool for managers to easily retrieve data from DB systems – not a tool for developers.


0 Responses to “Get schema-free within minutes using MongoDB”


  1. No Comments