It’s been far to long since I’ve talked here about what I’m working on, so it is time to correct that.  I’ve been working with a client who has some very unique business requirements, and one of them deals with a lot of flexibility of their data storage.  As such we were looking into different types of storage, because while SQL Server is in fact a wonderful product, it is not known for its flexibility of storage.

This quest led us to the door of a large number of databases in the “No SQL” arena, and eventually to MongoDB.  MongoDB is a document database, which stores what can best be described to the .NET Developer as a Dictionary<string,object>.  This structure allows for nesting of structures (where the object stored is another Dictionary) and is a very clever structure if you ask me.  But, document databases do not work like relational databases.  There are several important things you need to realize:

  1. Documents databases do not generally support the concept of JOINS.  If you retrieve data, and it refers to other data, then you need to make another call to the database to retrieve that data.
    • This leads to the core concept of preferring to embed (in the dictionary) data rather than refer to data.
  2. Document databases do not generally support a defined structure, they do not have tables but rather “collections” which have no definition in the database.  It is perfectly valid for one entry in a collection to have a key “dateOfAccount” which is a string type, and another with that same key as a date.
  3. Document databases do not include a validation structure, any validation of the data (including structural data as noted above) must be enforced by your application.

In the world of .NET there are several drivers, but the one my team, David O’Hara and Craig Neuwirt and I, decided on was MongoDB-CSharp.  They have just released version 0.9 beta 1, which moves the driver a lot closer to a familiarity level for most .NET developers.  Now we had to address on our project all of the above problems, and key to us doing so has been a component called DictionaryAdapater from the Castle Project.  But that is a topic for another blog post.