Software Development

RavenDB, a database alternative for .NET developers

Raven DB makes it easy to embrace a relational database management system alternative in your .NET applications. Get a feel for Raven DB and how it works with data.

The NoSQL movement is fighting the database establishment with relational database management system (RDBMS) alternatives. The surprising aspect of this movement is Microsoft's recognition and decision to embrace the RavenDB offering. We take a closer look at RavenDB.

Who needs a schema?

The NoSQL initiative developed out of necessity, because Google, Amazon, and other companies needed alternative ways to deal with vast amounts of data. The result is key-value stores such as BigTable or document storage such as CouchDB. Cloud storage solutions offer non-traditional (AKA non-RDBMS) storage as well with Window Azure Table Storage (based on key-value pairs) and Amazon's EC2 (based on Hadoop). The basic theme of these systems is speed and scalability, which isn't always an option with traditional database systems.

The basic underpinning of a relational database system like SQL Server or Oracle is the idea that data is stored in rows and columns that lead to a fixed schema. The growth of the Web and so-called big data has introduced areas where schema-based data is not the best approach.

While many predict the slow demise of RDBMS, I am not sold on that fact. However, I do realize that different situations require different tools, and I see a bright future of unstructured data storage as the amount and types of data available continue to grow. While this began an open source movement, Microsoft has fully embraced it with the Raven DB.

Never more

RavenDB is a document database designed for the .NET/Windows platform. It comes with everything you need to get started with non-relational data in your .NET application. Data is stored as schema-less JSON. There are a couple of ways to interact with this data: directly via HTTP and a RESTful API or via the more convenient .NET Client API. The .NET Client API uses LINQ-style syntax for working with the RavenDB document store.

Simple installation

You need to set up and install .NET Framework 4.0 before installing Raven DB. Then you download the latest version of RavenDB, which is available in a zip file that is extracted to a directory on your server. The included readme file contains additional setup information, but there are three ways you can utilize Raven DB: Windows Service, IIS application, or embedded in a .NET application.

The latest installation package includes these directories:

  • Client: Lightweight client for use with .NET 4.0.
  • Client-3.5: Lightweight client for use with .NET 3.5.
  • Silverlight: Silverlight 4.0 client.
  • EmbeddedClient: Files necessary for using RavenDB in embedded mode.
  • Server: Files required to use RavenDB in server mode.
  • Web: Files required to use RavenDB under IIS.
  • Bundles: Files for extending RavenDB in various ways.
  • Samples: Sample RavenDB applications to get you started.

Using the server

An easy way to get a feel for RavenDB and how it works with data is using the server mode. The following command is used to set up the server.

<Raven root directory>\Server\Raven.Server.exe /install
Once it is installed, the RavenDB UI is accessed via this URL on the server where it is installed: http://localhost:8080/raven/studio.html. Figure A shows the UI opened for the first time. The interface uses Silverlight, so you may be prompted to upgrade or install necessary Silverlight components. Figure A

RavenDB management interface (Click the image to enlarge.)
You can click the Create Sample Data button to populate a sample data store to get an idea of how the RavenDB document store works. Figure B shows one of the sample documents opened. Figure B

Viewing sample RavenDB document store (Click the image to enlarge.)
The data in Figure B (and the following listing) shows how data is stored in RavenDB. It stores album data with the following attributes: AlbumArtUrl, Artist, Genre, Price, Title, and Count Sold.
{

"AlbumArtUrl": "/Content/Images/placeholder.gif",

"Artist": {

"Id": "artists/133",

"Name": "Stevie Ray Vaughan & Double Trouble"

},

"Genre": {

"Id": "genres/6",

"Name": "Blues"

},

"Price": 8.99,

"Title": "In Step",

"CountSold": 0

}

The document has an id value, which is shown in Figure B (artists/633), but the artist value itself has an id value (artists/133) since artists can have multiple albums. Also, the genre has an id value (genres/6) since multiple albums are assigned to a genre. This data has a unique URL (http://localhost:8080/raven/studio.html#/edit?id=albums/614&database=Default), and you can access the other items via URL. For example, the genre information can be accessed with this URL: http://localhost:8080/raven/studio.html#/edit?id=genres/6&database=Default. The data can be edited as well as viewed via the Web interface. In the next column, we'll take a look at using RavenDB within a .NET application.

The future

Many NoSQL pundits predict the downfall of the traditional RDBMS, but each has their own application where the alternative is not appropriate. The RDBMS alternatives seem to have a bright future with heavyweights Google, Amazon, and Microsoft behind the various offerings. RavenDB makes it easy to embrace it now in your .NET applications.

How do you see the future of the database landscape? Are you using a non-traditional database platform? Share your thoughts with the community.

About

Tony Patton has worn many hats over his 15+ years in the IT industry while witnessing many technologies come and go. He currently focuses on .NET and Web Development while trying to grasp the many facets of supporting such technologies in a productio...

4 comments
Michael.Luna
Michael.Luna

Nice essay. So many in our field are absolutetism RDMS will have a place for long time and not going anyhere soon. The NoSQL database are here to fill a place.

motohead400
motohead400

I mean seriously, what does this do that SQL Server, Oracle, or mySQL can't do. Ooooo you can access it directly with HTTP (AND a RESTFul API). If only I could do that with any other database!!!?? No wait, you can already do that with anything. Why did this article even mention that? Sorry to be the skeptic, but I've seen so many databases over the years, and unfortunately had to use a few really horrid ones for projects against my will, and I just don't see any reason to move away from one of the 3 tried and proven ones currently used (mySQL, SQL Server, and Oracle).

Goober Bob
Goober Bob

Such closed minded people as yourself probably wonder why anyone would use anything but Windows as an OS and you were the one a few years ago saying smart phones were useless. You need to pay a little more attention as these type of document stores are being used by such companies as Google and Amazon and even Microsoft with their Azure offering (and their support of RavenDB). These companies also utilize RDBMS, so there may be a place for all.

Justin James
Justin James

... in being able to easily save values/data to a DB without having to pre-define a schema and jump through all of those hoops. It's MUCH easier and faster to develop when you don't need to deal with that. The trade off is that your documentation becomes much more critical and it's harder to work with other apps using the same data as a result. I suggest that you take a deeper look into "NoSQL" databases, since there is a lot more to them than how you access them, you may well find value in them for your projects. J.Ja