RavenDB - An Introduction
Introduction
RavenDB is a new open source document database for .NET. If you have never worked with a document database before, the simplest way to think about it is to imagine serializing your objects and storing them on the hard drive where the app is. If you stored it using the key or whatever most common lookup method you might use, it would be quite easy to retrieve your entire object without having to map to and from columns and rows in a SQL database. Dealing with further ways of looking it up, concurrency, etc. would be more difficult to deal with, hence the creation of document databases. The documents stored don't necessarily need to be an object that is serialized (arbitrary documents can be stored independent of objects), but that is probably the most common way it can be used. Just keep in mind that it is a completely different way of dealing with data storage so you probably don't want to always approach it as you would a SQL database. A .NET client is included for communicating with the server but the underlying representation is HTTP/JSON - so any client that can communicate with the server via HTTP/JSON will work.
Simple Example
Here is a simple example of how to store two arbitrary POCO objects in RavenDB, query for them and print out some of the information to the screen. In this example, the RavenDB server is on the same machine as the client but that doesn't have to be the case (more on that next). Notice that I didn't have to create a table, I didn't have to map columns and classes to the tables and I didn't have to create any stored procedures. The
Company
class isn't even marked as Serializable - it just works.
Also keep in mind that the creation of a
DocumentStore
object should be treated as an expensive operation, similar to creating a session factory in NHibernate
. Currently it isn't but there is future work planned that may change this.
No comments:
Post a Comment