Raven lovin' - .NET does NoSQL

Post on 27-Jan-2015

115 views 1 download

Tags:

description

 

transcript

RavenDB lovin’.NET does NoSQL

Evolve your data store,move beyond relational SQL

about:author

Raven in personal projects

Longtime user of ORMs

Raven at 3M

Raven with Ayende!

I’m no DBA! But…

Experienced in object DBs

RavenDB? Why do we need anything besides SQL?

SQL: Databases done right.

Circa 1970.

SQL: Databases done right.

Circa 1970. ACID.

Popular in the ‘70s, man. But it makes scaling difficult.

CAP Theorem for distributed systems:

Consistency, Availability, Partition toleranceChoose 2.

SQL: Databases done right.

Circa 1970. Got ACID? Scale up. Pay up.

SQL: Databases done right.

Circa 1970. How many queries for this simple page?

SELECT UPPER(Name) FROM Customer WHERE Name LIKE'A%' ORDER BY Name

SELECT UPPER(Name) FROM ( SELECT *, RN = row_number()

OVER (ORDER BY Name) FROM Customer WHERE Name LIKE 'A%' ) A WHERE RN BETWEEN 21 AND 30 ORDER BY Name

SELECT TOP 10 UPPER (c1.Name) FROM Customer c1 WHERE c1.Name LIKE 'A%' AND c1.ID NOT IN ( SELECT TOP 20 c2.ID FROM Customer c2 WHERE c2.Name LIKE 'A%‘ ORDER BY c2.Name ) ORDER BY c1.Name

$ SET SOURCEFORMAT “FREE”IDENTIFICATION DIVISION.Display Prompt. DISPLAY “I <3 SQL!”. STOP RUN.

Or how about…var names = db.Customers .Where(c => c.Name.StartsWith(“A”)) .OrderBy(c => c.Name) .Select(c => c.Name.ToUpper()) .Skip(20) .Take(10);

SQL: Databases done right.

Circa 1970. 1974 called. They want their query language back.

SQL: Because objects and relational databases go together

like peanut butter and tuna fish

•Polymorphism doesn’t exist in the relational world•Encapsulation creates fragile database models•Inheritance results in inefficient relational queries•Leaky abstraction

The object-relational impedance mismatch:

SQL + OO =Peanut butter +

Tuna.

SQL + OO =Object-Relational Mapppers (O/RMs) like Entity Framework attempt to hide these problems…

…but you can mask the tuna only so long…

SQL + OO =var today= DateTime.Now;context.TheBaseTypes .Where(b => b.DateCreated == today) .ToList();

“Expressing this query in LINQ to Entities is short and sweet. But don’t be fooled. It’s a hefty request. You’re asking EF and your DB query each table that maps to the derived entities and join each one to the BaseTypes table.

In my environment, this creates a 3,200 line SQL query, which can take Entity Framework some time to build and the database some time to execute.”

-Julie Lerman, MSDN Magazine, August 2012

ORM: The Vietnam of Computer Science

“ORM is the Vietnam of Computer Science.

It represents a quagmire which starts well, gets more complicated as time passes, and before long entraps its users in a commitment that has no clear demarcation point, no clear win conditions, and no clear exit strategy.”

-Ted Neward

SQL: The Hammer for

every nail

“The first to present his case seems right, till another comes forward and questions him.”

…and every screw

NoSQL: A modern alternative to relational

databasesNoSQL databases:

Don’t use T-SQL

Typically schema-free

Relax ACID guarantees

Built for distributed scalability

NoSQL: A modern alternative to relational

databasesNoSQL: weaning us off ACID

to achieve more psychedelic things

Trippy things like…

Cheap, fast reads

Horizontal scalability

Flexible, schema-free models

NoSQL has problems, too.

:-(

NoSQL has problems, too.

:-(

Painful query models

Immature tooling

Complex APIs

Poor language support

RavenDBAn opinionated, 2nd generation NoSQL database

“I’ve consulted on NHibernate and other ORMs for over a decade. I’ve seen the same problems repeated over and over.

I wanted to fix that.So I created RavenDB.”

-Ayende

RavenDBAn opinionated, 2nd generation NoSQL database

Get out of the RDBMS/ORM mess

Fix shortcomings of NoSQL

“I intentionally designed RavenDB and its .NET API to deal with problems and frustrations in the NHibernate / RDMBS model.”

-Ayende

Evolve data storage

RavenDBAn opinionated, 2nd generation NoSQL database

Setup should be painless

RavenDBAn opinionated, 2nd generation NoSQL database

Simple is better

RavenDBAn opinionated, 2nd generation NoSQL database

Putting stuff in the database should be easy

RavenDBAn opinionated, 2nd generation NoSQL database

Transactions are important

RavenDBAn opinionated, 2nd generation NoSQL database

LINQ is the best query language on the planet

RavenDBAn opinionated, 2nd generation NoSQL database

Developers should fall into the pit of success

RavenDBAn opinionated, 2nd generation NoSQL database

Reads should be *fast*. Index fast.

Lock-free, non-ACID reads

“Better stale data quickly than live data slowly.”

Indexes should be created automagically

Every read is a query against an index. Yes!

RavenDBAn opinionated, 2nd generation NoSQL database

Tooling is important

RavenDBAn opinionated, 2nd generation NoSQL database

Search matters. Google-like search.

RavenDBAn opinionated, 2nd generation NoSQL database

Scalability should be easy, natural

Replication: master-to-slave, master-to-master Sharding: split your data across servers

transparently

Recap!

Raven is super

fast!

Raven is easy!

Raven is scalable! Raven is magical !

It’s an alternative to the SQL + ORM mess

You should totally use it for your next project :-)

Thank You!Hope this has helped!

Slides: bit.ly/raventalk

Twitter: @JudahGabriel

Blog: DebuggerDotBreak.wordpress.c

om