1. NoSQL for you
AN INTRODUCTION TO DOCUMENT DATABASES USING RAVENDB
NOSQL FOR YOU
Kevin Krueger, Principal Consultant kevin@solutionwave.net
SolutionWave @kevinkrueger
2. What is NoSQL?
“non SQL” or “not-only SQL”
From Wikipedia: “provides a mechanism for storage and
retrieval of data that is modeled in means other than the
tabular relations used in relational databases”
NOSQL FOR YOU
3. Types of NoSQL Databases
Key-Value Store (Riak, Amazon Dynamo)
Document Database (RavenDB, CouchDB, MongoDB)
Graph Database (Neo4j)
NOSQL FOR YOU
4. NOSQL FOR YOU
DocumentDB (documents, not rows)
Non-relational
Schema-less
Transactional*
REST API and .Net Client
5. Why choose a Document Database
instead of a Relational Database?
NOSQL FOR YOU
There is an inherent mismatch between object models and
relational models (aka the ORM impedance mismatch)
◦Set vs. graph relationships
ORMs end up being a leaky abstraction
◦Inefficient SQL (e.g. SELECT N+1 issue)
◦The database schema ends up driving your object model
8. Indexes
Every query (beyond retrieval by document id) requires an
index
◦Indexes teach Raven about your data
◦Raven uses Lucene.Net behind the scenes for indexing
Raven will automatically create indexes for you on the fly
It’s better to explicitly create them up front
Indexes can be stale (eventual consistency)
NOSQL FOR YOU
10. Things to be aware of:
Raven is built with a “safe by default” principle
◦These limits can surprise you
Eventual consistency requires careful consideration
◦Your application’s behavior shouldn’t depend on indexes being
non-stale
NOSQL FOR YOU
11. Bundles
Bundles are packages of additional functionality that can
optionally be installed. Examples:
◦Authorization
◦Cascade delete
◦Encryption
◦More like this
◦Unique constraints
◦Versioning
NOSQL FOR YOU
12. Advanced topics for you to explore
Advanced indexes
◦Multi-map indexes
Transformers: server side projections
Listeners: client-side extension points
◦Example types: Store listeners, Conversion listeners
Data subscriptions (pub/sub)
Patching API: useful for updating denormalized data
In-memory mode: great for unit tests
NOSQL FOR YOU
13. Thoughts on NoSQL
It’s not a one-size fits all solution.
Sometimes NoSQL doesn’t make a lot of sense:
◦ e.g. Ad-hoc reporting
It’s another tool to put in your tool belt. Use it strategically where it
makes sense.
◦ Semi-structured data
◦ Hierarchical data
NOSQL FOR YOU
14. Summary
Raven is a NoSQL Document Database
Documents are stored in JSON
The .Net API supports queries using Linq
Indexes specify the fields in your documents that can be
searched on
NOSQL FOR YOU
Indexes are not consistent in a transaction. They are eventually consistent
Document databases remove this impedance mismatch
Show the Raven install and how you start it up
After demo, show how automatic indexes were created
TIME PERMITTING
Remember: there are no relationships in a document databases
This requires a change in thinking from relational databases
Without this denormalization, you’d have to load the entire customer document to get the customer details you want to display
Aggregate roots in DDD
Examples:
You can only retrieve 128 documents at a time
There is a limit of 30 requests per session