Raven DB Basics

In this blog, I will try to understand the basics of NoSQL databases. I will also try to see how one of the NoSQL databases i.e Raven DB works.

NoSQL means dbs without SQL i.e these dbs are not relational. There are many types of NoSQL dbs -
  • Wide column store - more focussed on columns. Consists of row, column and time.
  • Document Store - Raven DB is document store. Data stored as a single document. Contains key and the document.
  • Key Value - similar to document store except value can be anything.
  • Object DBs - stores objects instead of tables.
  • Graph DBs - Data connected to each other via nodes. Facebook uses this kind of db.
Raven DB - Raven DB is a non relational (schema less) document store. It uses JSON format to store the data. Raven DB also supports transactions. Raven DB also stores some metadata about the document. We can also store attachments like images in binary format. Indexes in Raven DB are pre-canned LINQ queries. We communicate with Raven DB over HTTP. Raven exposes the data in form of JSON similar to a REST based web service. By the way, Raven means a family of birds who typically have large beaks and black plumage. Crows come from the Raven family.
Let's take a look at a simple application that does the basic CRUD operations on a Raven DB using Raven Client for .NET. I have installed the Raven db client via nuget. The code looks like:
And the output is:

Here, besides the CRUD examples, you can also see that Raven provides an easy interface to query the data using session.Query construct. With this, simple LINQ queries can be executed on the db. Since this is a document store, we can not use certain LINQ queries such as Join, Union etc. Another point to note is that all the queries were executed by utilizing the basic HTTP verbs. We can look at fiddler for every request made to see the same.
We are also creating a simple index "PeopleByName". PeopleByName index select the persons by name. Then in the QueryExample method we execute a query to select all persons whose name starts with an "R" by using this index. Indexing in Raven also supports other advanced features such as grouping, aggregation, transform, reduce etc.