Thinking in a document centric world with RavenDB by Nick Josevski
-
Upload
nick-josevski -
Category
Technology
-
view
110 -
download
3
description
Transcript of Thinking in a document centric world with RavenDB by Nick Josevski
Thinking in a document centric world
with RavenDB
There’s got to be a better way,
Somewhere over the…
We’re off to see the Wizard
What is RavenDB?
• It is a Document Store• Built with .NET• Fast• Easy to use / program against• Currently only runs on Windows• If you’re wondering it supports MSDTC• Open source
SOME BASIC CONCEPTS
CAP Theorem
• Consistency• Availability• Partition Tolerance
• When you suffer a network partition between stores.• You decide how much Consistency OR Availability you would
like to have.
Documents are not flat
• A single document can be a complex object graph.
• It’s no longer a challenge to store your data• You’re no longer in a relational world– Schema-free data store– Does not mean chaos as some would lead you to
believe
More info on this at: http://ravendb.net/docs/theory/document-structure-design
Eventual Consistency
• In RavenDB– Writes occur against the document store.– Queries occur against the index store.– Single Load operations go directly to the
document store.
• RavenDB is more consistent than others• Also: not all viewers of data should be
considered equal.
Eventual Consistency
• Step 1 : Optimise for reading,
• Step 2: by prioritising Availability higher than Consistency
• Step 3: (Index is stale)
• Step 4: Profit
GETTING STARTED
Installation
Raven Management Studio
USING RAVEN DB
Using Raven in your .NET Code
Just like any (good) ORM
• Persist Document
• Loading
• Queries
Unit of Work Pattern
• With IDocumentSession– Open a session of work– Make changes in memory– Persist changes
Search Capabilities
• Search is delegated to Lucene.NET– Full text indexing
FETCH / QUERY
Session.Include
• The simplest way to start retrieving documents and other associated documents
Session.Query
• It is just LINQ• Pagination via:– .Skip() and .Take()
Session.Customize
• As part of a query retrieve associated documents
Safe by Default
• 3 magic numbers to help you out– Default page size limit 128– Take(n > 1024) is still 1024
– Requests 30 • Why so many calls?
• Overridable via configuration, for those SELECT * FROM addicts
Transformers
• Server side projections – with the ability load data from other documents– RavenDBs true power shining through
Simple Transformer
Real World Example
Real World Example
INDEXES
Indexes
• With the power of schema-less store• Comes great (some) responsibility• Raven doesn’t know about fields on your
document by default• So if you haven’t set up indexes raven will help
you out
Indexes
• Extend Abstract Index Creation Task
Map / Reduce
• Just like previous examples except there’s a reduce component
• Most trivial examples is summing up totals/counts of items
Map / Reduce
Multi-Map
• Querying Unlike Documents• To build up something that doesn’t exist• We’re working with documents– No need for left/inner/outer/right/middle joins
Multi-Map
Real World Example
PROFILING
Profiling is first class
• Fiddler is your friend
• For your ASP.NET MVC App1.
2. In Global.asax.cs
3. In _layout.cshtml
• Demo app up at: https://github.com/NickJosevski/ravendb-presentation
ASP.NET Profiling Integration
ASP.NET Profiling Integration
REAL WORLDMore in the
Raven in Apps
Structure of our Documents
• Varies and has been tuned for each use case• But can be summarised into 3 types
Network of Documents
Single Documents
Single Documents
Parent & Child Documents
4th type and no longer used
• When we started with Raven• We started down a path of “Summary”
Documents – Which became a problem to maintain
• Replaced with Transformers outputting SummaryDTOs
Deploying Indexes/Transformers
IOC Container Registration
Document Conventions
Projectors
More Info / Sources
• http://ravendb.net/• Tekpub (series now on Pluralsight)• RavenDB High Performance by Brian Ritchie• NoSQL video from Martin Fowler– http://www.youtube.com/watch?v=qI_g07C_Q5I
• Reach out to me Nick Josevski– 1st video recording of this:– http://www.youtube.com/watch?v=u3kUpFlf76M
Thanks
• Questions?