Slide 1

Slide 1 text

Introducing RavenDB Agile Persistence in .Net

Slide 2

Slide 2 text

About Johnny Graber •Software Engineer - Swiss Medical Association •Twitter: @j_graber •E-Mail: [email protected] •Blog: ImproveAndRepeat.com Examples at

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Today’s Main Topics •NoSQL •RavenDB •Agile Persistence

Slide 5

Slide 5 text

Demo RavenDB .Net Client How simple is it to access RavenDB?

Slide 6

Slide 6 text

NoSQL?

Slide 7

Slide 7 text

No SQL

Slide 8

Slide 8 text

Not only SQL

Slide 9

Slide 9 text

Polyglot Persistence

Slide 10

Slide 10 text

Relational Databases aren’t Obsolete

Slide 11

Slide 11 text

Great for •Optimized Writes •Minimal Storage Footprint •Flexible Querying

Slide 12

Slide 12 text

But •Mostly Reads in Our Applications •Storage Costs (Almost) Nothing •Hard to Scale

Slide 13

Slide 13 text

NoSQL Provides Solutions

Slide 14

Slide 14 text

Main Types of NoSQL •Key / Value Store •Graph Database •Column Database •Document Store

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

RavenDB •2nd Generation Document Database •Built on .Net •Schema Free

Slide 17

Slide 17 text

Some RavenDB Features •Safe by Default •Supports Transactions (ACID) •Best Practices Built in

Slide 18

Slide 18 text

A Document in RavenDB •Self-Contained •Independent •Redundant Data (History)

Slide 19

Slide 19 text

A Document in RavenDB

Slide 20

Slide 20 text

Running RavenDB •Standalone Server •Part of Your Web-Application •Embedded Mode

Slide 21

Slide 21 text

Installing RavenDB

Slide 22

Slide 22 text

RavenDB Studio •Look Into the Database •Generate Sample Data •Administration Tools

Slide 23

Slide 23 text

Demo RavenDB Studio How does the administration interface works?

Slide 24

Slide 24 text

Connect to RavenDB •.Net Client Install-Package RavenDB.Client •HTTP API

Slide 25

Slide 25 text

Demo HTTP API Can you use RavenDB without .Net?

Slide 26

Slide 26 text

Querying RavenDB var books = from books in session.Query() where books.Title.StartsWith("Raven") select books; var book = session.Load("books/1");

Slide 27

Slide 27 text

Indexes in RavenDB •All Queries Need an Index •Static or Dynamic •Created in Background (Stale Index)

Slide 28

Slide 28 text

Challenges for Index Creation •Schema Free Data •Fixed Structure to Find Data •Closing the Gap with Map/Reduce

Slide 29

Slide 29 text

Map/Reduce This is probably the most common error that people make with any sort of data access technology. "Just give me the whole thing, I'll make sense of it on the client side." In the RDBMS world, this would be expressed as "SELECT * FROM Orders". The problem with such queries is they can potentially… Map Reduce

Slide 30

Slide 30 text

Demo Index Creation How hard can it be?

Slide 31

Slide 31 text

Licencing RavenDB •AGPL for Open Source Projects •Commercial Licence: 399$/Year/Instance •RavenHQ: Starting at 10$/Month

Slide 32

Slide 32 text

Agile Persistence

Slide 33

Slide 33 text

Development Today •Agile Approach •Embrace Change •Fail Fast

Slide 34

Slide 34 text

Except in the Persistence Layer •First Time Right •Hard to Change •Don’t Touch

Slide 35

Slide 35 text

“When the Database must be correct the first time, every part of the application must be known at the beginning”

Slide 36

Slide 36 text

“Persistence should be an application detail”

Slide 37

Slide 37 text

Domain-Driven Design •Aggregates •Bounded Context •Entity or Value Object

Slide 38

Slide 38 text

Benefits of Following DDD Principles •History of Documents •Complete Change Tracking •Optimised Data Access

Slide 39

Slide 39 text

Command Query Responsibility Segregation (CQRS) •Commands Modify State •Queries Answer Questions •Keep Them Apart

Slide 40

Slide 40 text

CQRS for Fast Applications

Slide 41

Slide 41 text

CQRS and RavenDB •HTTP API (REST ) •When Unauthenticated Only Allow Read •Done

Slide 42

Slide 42 text

TDD and RavenDB •Don’t Abstract an Abstraction Layer! •Use In-Memory Mode •It’s Fast Enough

Slide 43

Slide 43 text

Changing Documents •Easily Done •Know the Impacts •Worst Case: Full DB Update

Slide 44

Slide 44 text

Demo Schema Change How can you change your schema?

Slide 45

Slide 45 text

Use RavenDB •Hacking •Pet Projects •Prototypes

Slide 46

Slide 46 text

Try This at Home NOT in Production!

Slide 47

Slide 47 text

What’s Missing •Authorisation & Authentication •Bulk Inserts •Paging •Sharding

Slide 48

Slide 48 text

More on RavenDB •RavenDB.net •Tekpub.com •ImproveAndRepeat.com

Slide 49

Slide 49 text

More on Polyglot Persistence •Martin Fowler: http://martinfowler.com/bliki/CQRS.html •Jimmy Bogard: Real World Polyglot Persistence http://vimeo.com/68320412

Slide 50

Slide 50 text

Questions? [email protected]

Slide 51

Slide 51 text

Thank You!