NoSQL with RavenDB

In the strongly typed world we have to predefine data structures expressed with language elements such as structs and classes. However in a dynamic web world there is a greater flexibility, especially with a dynamic language as JavaScript, native browser support for JSON and jQuery libraries.

If your data is relational and fixed in the sense that there is a predefined schema, then a relational database would solve your problem just fine. However, if the problem domain is not relational in its nature, then other data structures might be better suited.

When dealing with free text qualitative data, there is really no connections that could be modeled between different sets of data. Instead a data structure of independent documents would be more suitable.

As a .NET developer the document database RavenDB is attractive since it provides us with a built-in .NET API, HTTP API and many of the features a NoSQL database can offer. In a web environment the HTTP API is useful because it could eliminate the need for a middle tier for simple scenarios where you don’t need all the features the server side could offer. In RavenDB all documents are stored as JSON and its input and output is also JSON.

Since RavenDB is built in .NET, the natural way of using it is from .NET code. It is very easy to store and fetch strongly typed objects since RavenDB has APIs for doing the mapping transparently. However, you are not forced to use .NET code only. From JavaScript we can call the database directly with RavenDB’s RESTful API. The mapping to a .NET class is stored as metadata with a fully qualified name. This is the only difference between a .NET mapped document and a document without any .NET type.

In RavenDB, you have to create indexes as Map/Reduce functions written as LINQ-queries. These indexes could make use of document properties, metadata or both.

The same logic is applied to collections in RavenDB; it is just some metadata specifying the Raven-Entity-Name. The major difference between this attribute and other metadata is that the Raven-Entity-Name could be used in indexes like this:

Of course you can add your own metadata and use it in your own indexes.

My personal findings about RavenDB are that it is very easily deployed; you can use xcopy to a website in Internet Information Services, IIS, with all of the features it offers.
The database itself is quite straight forward but there are still things that need to be improved in the eco-system, such as management tools and more extensive documentation.

It is really nice to use Linq syntax to create indexes if you know C#, but you really have to think differently than you do when using a traditional relational database. You cannot write SQL to query RavenDB. However, in most cases it is possible to get the data you want by creating indexes.

Just remember, you store documents, not relational data.

One Response to “NoSQL with RavenDB”

  1. And you can find RavenDB here: http://ravendb.net/. The Google group is a good place to ask question: https://groups.google.com/forum/#!forum/ravendb
    ;-)

Leave a Reply