Hello RavenDB! Introducing RavenDB for ASP.NET Developers

In this article, we will look at a NoSQL database called RavenDB. If you are new to NoSQL or RavenDB or Document Databases, don’t panic! We’ll walk you through an introduction for each.

What is NoSQL and what are NoSQL Databases?

Before we get into the classical definition, let’s look back at our approach towards building n-layer ASP.NET applications. Typically we have the RDBMS system with its schema at the bottom, immediately followed by an O-R Mapping layer that maps the tables into Entities. Rest of the application layers, are built on top of this entity layer. Be it business logic or View model, everything is supposed to work off the entity layer at the minimum. Views could be interacting with View layers etc.

This mandatory mapping from Tables to Entities often involves a non-trivial amount of work to shoehorn object relationships into table structures. At this point we all wonder, wouldn’t it be nice if we could just think in term of entities/business objects and by pass the O-R layer altogether?

NoSQL databases (specifically the Object Database or Document Database breed), aim to release us from this ‘impedance-mismatch’ of entities that we use for business logic and tables that we use for data storage, by saving Business Entities directly to a persistence store.

NoSQL as is somewhat obvious, stands for ‘Not only SQL’. Martin Fowler recently posted on his blog that calling NoSQL as ‘Not only SQL’ is unnecessarily polite. It should mean ‘NO-SQL’. Whichever way we go with the naming, NoSQL systems are schema-less and they can retrieve/store data either as complete object graphs or as key value pairs. A very good primer and categorization of NoSQL databases is available at http://nosql-database.org/. In short, NoSQL databases take a clean break from the table/column schema RDBMS and are designed with horizontal scaling, simpler serialization and commodity hardware requirements in mind.

Welcome RavenDB!

  • RavenDB is a Document Store (a type of NoSQL) database written in .NET. By Document Store, it does NOT imply you can store MS Word documents or Excel Spreadsheets in them. Here document stands for an object graph. Document Store DBs serialize object graphs to the data store directly.
  • The data is serialized as standard JSON stream.
  • Oren Eini (Ayende Rahien) at Hibernating Rhinos created RavenDB. It started out as a pet project that he used to learn the NoSql architecture. It has now grown to become a full-scale commercial NoSql database.
  • It is available under dual licenses (community and commercial).
  • It runs either on IIS or as a Windows Service
Unlike most NoSQL databases that adhere to the BASE properties, RavenDB supports ACID properties for write operations. (Indexing is however still ‘eventually consistent’ but RavenDB will tell you if it is getting you stale data). ACID as we call knows stands for (Atomicity, Consistency, Isolation and Durability) and support for ACID is what makes us so comfortable using RDBMS systems with respect to Data Integrity. BASE on the other hand stands for Basically Available, Soft state, Eventual consistency. You can read up more on BASE and CAP Theorem if you want to.

RavenDB still has a weakness that prevents it from becoming the instant choice of all green-field (a project starting fresh) ASP.NET MVC web projects. Most reporting solutions today work best off RDBMS systems and NoSQL databases are just getting their feet wet with respect to Reporting system connectivity.

So if you are building a system that doesn’t require traditional reporting systems to hook in and retrieve data, RavenDB is the perfect choice. More often that not, that’s not the case (specially Line of Business applications) and hence we tend to fallback on SQL Server/MySQL/Oracle etc.

I will soon post an article where we will see a use case that is typical of brown-field projects (projects involving enhancements to an existing application) where a handy functionality can be achieved by using RavenDB and ASP.NET MVC.

Update: To learn how to use RavenDB in an MVC project, check Using RavenDB in Brown-Field ASP.NET MVC projects





4 comments:

Anonymous said...

The link to "Using RavenDB in Brown-Field ASP.NET MVC projects" was not working. I Googled the title and found this:

http://www.dotnetcurry.com/ShowArticle.aspx?ID=784

Suprotim Agarwal said...

Sorry about that. Fixed! Thanks!

David Grant said...

Concept has achieved the .NET group on the pizza of a raven about a new choice for a NoSQL-type data-layer rendering. The discovering contour for getting up and managing with an example of RavenDB is shorter and lovely. Actually, the item that may need the most planning is the certification strategy.

Dag Magnusson said...

Oh really informative post actually i am suffering a lot of time on internet but now i got what i want.Thanks again keep sharing