Beginning RavenDB quick start Reply

2_bgThere has been a lot of buzz in the development community concerning no SQL databases.  That’s right a database used to persist data for an application that involves no SQL period.  How does this work?   How do I construct tables or even perform basic CRUD operations with out SQL? The answer is you don’t.  RavenDB is a schema free database with no concept of tables and rows or mappings or the typical stuff that goes with SQL server or MySQL and so on.  It is a place you can simply dump your application objects into and easily access later.  This alone saves a good deal of time.

RavenDB is a document database.  A database that stores documents. The documents are actually application objects like an object graph comprised of entities such as Customer with an Order with related Order Details serialized as JSON object then stored in RavenDB. That’s it. Once this object graph is saved in RavenDB it can be consumed by any technology that can consume JSON objects.  RavenDB is platform agnostic consumed by .NET, JAVA, smart phones you name it. Since RavenDB is restful by nature it lends it self very well to web technologies. That concept opens many possibilities for the consumer of a Raven database.

If you wanted to quickly get some code off the ground RavenDB could save you time in getting started.  It takes about 15 minutes to get RavenDB installed, start the Raven Server and referenced in your code for real time usage.

RavenDB is an available through Nuget and once included in you project your almost ready to start developing.  The details to get going with RavenDB are here: Add RavenDB to your project.  When added to your project and installed you can now start RavenDB by  navigating to <<your install location>>\RavenDB\RavenDB-Build-573\Server\Raven.Server.exe.  Raven is now running.

After you start Raven.Server you will see the following command window.  The URL highlighted in the window is used in code to access it like a connection string.

Raven.Server started

Now to actually use RavenDB in a project you simply do something like this:

//Get an instance of RavenDB's document store and start it.
var RavenDB = new DocumentStore { Url = "http://davepease-ibs:8080" };
RavenDB.Initialize();

//Saving custom object to RavensDB's document store.
using (var Raven = RavenDB.OpenSession())
{

    Raven.Store(new Order
    {
        Customer = "customers/Johnny",
        OrderLines = 
        { 
            new OrderLine
            {
                ProductId = 50,
                Quantity = 3,
                Name = "Ipad2"
            },
        }
    });

    Raven.SaveChanges(); 
}

A new order has been added to RavenDB. That’s it.

In summary, I discussed what a document database is and how it differs from a traditional SQL database.  What makes RavenDB so easy to use and how to actually use it in a real world development scenario.  In my next posts I will discuss possible scenarios for RavenDB.

You can find all the details on RavenDB here:http://ravendb.net/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s