relational vs. non-relational

98
Relational vs. Non-Relational Josh Berkus PostgreSQL Experts Inc. SCALE 2010

Upload: postgresql-experts-inc

Post on 22-Nov-2014

3.221 views

Category:

Technology


6 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Relational vs. Non-Relational

Relationalvs.

Non-Relational

Josh BerkusPostgreSQL Experts Inc.SCALE 2010

Page 2: Relational vs. Non-Relational

2003:● MySQL● PostgreSQL● FireBird● BerkeleyDB● Derby● HSQLDB● SQLite

Page 3: Relational vs. Non-Relational

2003:● MySQL● PostgreSQL● FireBird● BerkeleyDB● Derby● HSQLDB● SQLite

Page 4: Relational vs. Non-Relational

2010● MySQL● PostgreSQL● FireBird● BerkeleyDB● Derby● HSQLDB● SQLite

Page 5: Relational vs. Non-Relational

“NoSQL movement”

Page 6: Relational vs. Non-Relational

Allnon-relational

databases

Page 7: Relational vs. Non-Relational

Are notthe same

Page 8: Relational vs. Non-Relational

Graph

K ey-va lue

Document

H ierarchic a l

D is tributed

Neo4JHyperGraphDBJena

CouchDBBerkeleyDB-XMLS olr

MemcachedTokyo Cabinetdb4oR IAK

CassandraHypertableMyS QL NDB

MongoDB

Page 9: Relational vs. Non-Relational

All relationaldatabases

Page 10: Relational vs. Non-Relational

Are notthe same

Page 11: Relational vs. Non-Relational

Embedded

M PP

OLTP

S treaming

C -S tore

S QLiteFirebirdHS QL

PostgreS QLMyS QLOracleS QL S erver

TeraDataGreenplumAster

LucidDBMonetDB

S treambaseTruviso

Page 12: Relational vs. Non-Relational

NoFinsNoFins

Page 13: Relational vs. Non-Relational
Page 14: Relational vs. Non-Relational

“NoSQL movement”

Page 15: Relational vs. Non-Relational

Mythbust #2

Page 16: Relational vs. Non-Relational

“revolutionary”

Page 17: Relational vs. Non-Relational

There

Page 18: Relational vs. Non-Relational

are

Page 19: Relational vs. Non-Relational

no

Page 20: Relational vs. Non-Relational

new

Page 21: Relational vs. Non-Relational

database

Page 22: Relational vs. Non-Relational

designs

Page 23: Relational vs. Non-Relational

There are only newimplementations

andcombinations

Page 24: Relational vs. Non-Relational

“A database storing application-friendly formatted objects, each

containing collections of attributes which can be searched

through a document ID, or the creation of ad-hoc indexes as needed by the application.”

Page 25: Relational vs. Non-Relational

CouchDB, 2007

Pick, 1965

Page 26: Relational vs. Non-Relational

CouchDB, 2007 embeddable Pick

JSON storageREST API

map/reduce

Page 27: Relational vs. Non-Relational

“revolutionary”

Page 28: Relational vs. Non-Relational

“revolutionary”

Page 29: Relational vs. Non-Relational

“renaissance of

non-relational databases”

Page 30: Relational vs. Non-Relational

Mythbust #3

Page 31: Relational vs. Non-Relational

“non-relationaldatabasesare toys”

Page 32: Relational vs. Non-Relational

Bigtable

Google

Page 33: Relational vs. Non-Relational

Dynamo

Amazon

Page 34: Relational vs. Non-Relational

Memcached

FaceBook

Page 35: Relational vs. Non-Relational

Pick, Caché

US Vetrans' Administration

Page 36: Relational vs. Non-Relational

Mythbust #4

Page 37: Relational vs. Non-Relational

“Relational databases

will become obsolete”

Page 38: Relational vs. Non-Relational

“Three decades past, the relational empire conquered the hierarchical

hegemony. Today, an upstartchallenges the relational empire's

dominance ...”

--Philip Wadler, Keynote VLDB, Rome, September 2001

XML Databases2001

Page 39: Relational vs. Non-Relational

Anyone rememberXML databases?

Page 40: Relational vs. Non-Relational

No?

Page 41: Relational vs. Non-Relational

What happened?

Page 42: Relational vs. Non-Relational

established relationaland non-relational

databaseshybridized XML

Page 43: Relational vs. Non-Relational

Oracle XMLPostgreSQL XML2BerkeleyDB XML

DB2

Page 44: Relational vs. Non-Relational

Mythbust #5

Page 45: Relational vs. Non-Relational

“Relational databases are for when you need

ACID transactions.”

Page 46: Relational vs. Non-Relational

Transactions

≠Relational

Page 47: Relational vs. Non-Relational

Robust Transactions without Relationality:

SQL Without Transactions:

BerkeleyDBAmazon Dynamo

MySQL MyISAM

MS Access

Page 48: Relational vs. Non-Relational

Mythbust #6

Page 49: Relational vs. Non-Relational
Page 50: Relational vs. Non-Relational

You

Page 51: Relational vs. Non-Relational

do

Page 52: Relational vs. Non-Relational

not

Page 53: Relational vs. Non-Relational

have

Page 54: Relational vs. Non-Relational

to choose

Page 55: Relational vs. Non-Relational

onedatabase.

Page 56: Relational vs. Non-Relational

Choosethe database system

which fi ts yourcurrent

application goals.or ...

Page 57: Relational vs. Non-Relational

Use more than one together

MySQL + MemcachedPostgreSQL +

CouchDBor ...

Page 58: Relational vs. Non-Relational

Use a Hybrid

MySQL NDB

PostgreSQL Hstore

HadoopDB

Page 59: Relational vs. Non-Relational

But what about relational

vsnon-relational?

Page 60: Relational vs. Non-Relational

Relational OLTP Databases*

● Transactions: more mature support– including multi-statement

● Constraints: enforce data rules absolutely● Consistency: enforce structure 100% ● Complex reporting: keep management happy!● Vertical scaling (but not horizontal)

* mature ones, anyway

Page 61: Relational vs. Non-Relational

SQL vs. Not SQL

SQL promotes:● portability● managed changes over time● multi-application access● many mature tools

Page 62: Relational vs. Non-Relational

SQL vs. Not SQLBut …SQL is a full programming language, and you have to learn it to use it.

Page 63: Relational vs. Non-Relational

SQL vs. Not SQL

No-SQL allows:● programmers as DBAs● no impedance● fast interfaces● fast development

Page 64: Relational vs. Non-Relational

The main reason to use SQL-RDBMSs

Page 65: Relational vs. Non-Relational

“Immortal Data”your data has

a life independent

of this specifi capplication implementation

Page 66: Relational vs. Non-Relational

How do Ichoose?

Page 67: Relational vs. Non-Relational

Defi ne the problemyou are trying

to solve

Page 68: Relational vs. Non-Relational

● “I need a database for my blog”● “I need to add 1000's of objects per second on a low-

end device.”● “I need my database to enforce business rules across

several applications.”● “I want my application to be location-sensitive.”● “I need to cache data an access it 100K times per

second.”● “I need to produce summary reports across 2TB of

data.”● “I have a few hundred government documents I need

to serve on the web and mine”● “I need to know who-knows-who-knows-who.”● “I need to data mine 1000's of 30K bug reports per

minute.”

Page 69: Relational vs. Non-Relational

Defi ne the featuresyou actually need

● many connections● multi-server scalability● complex query logic● APIs● redundancy● data integrity● schema/schemaless● data mining

Page 70: Relational vs. Non-Relational

fi t the databaseto the task

Page 71: Relational vs. Non-Relational

“I need a databasefor my blog”

Page 72: Relational vs. Non-Relational

Use anything!● MySQL● PostgreSQL● MongoDB● SQLite● CouchDB● Flatfi les● DBaseIII● Something you wrote yourself

Page 73: Relational vs. Non-Relational

“I need my databaseto unify several applications and

keep them consistent.”

Page 74: Relational vs. Non-Relational

PostgreSQL“OLTP

SQL-Relational Database”

“It's not just a database: it's a development platform”

Page 75: Relational vs. Non-Relational

Postgres 9Postgres 9

alpha out now!alpha out now!

Page 76: Relational vs. Non-Relational

“I need my applicationto be location-aware.”

Page 77: Relational vs. Non-Relational

PostGIS“Geographic Relational

Database”

Page 78: Relational vs. Non-Relational

PostGIS● Queries across “contains” “near” “closest”● Complex geometric map objects

– polygons– lines (roads, etc)

● Make your own Google Maps!– Sunday, 4:30pm, Concourse A

Page 79: Relational vs. Non-Relational

“I need to store1000's of event objects

per second on embedded hardware.”

Page 80: Relational vs. Non-Relational

db4object“Embedded Key-Value

Store”

Page 81: Relational vs. Non-Relational

db4object● German Train System● Insert 1000's of objects per second● Low-end embedded console computer● Simple access in native programming language

(Java, .NET)

● compromise: embedded SQL database:SQLite

Page 82: Relational vs. Non-Relational

“I need to access 100K objects per

secondover 1000's of connections.”

Page 83: Relational vs. Non-Relational

memcached“Distributed In-Memory

Key-Value Store”

Page 84: Relational vs. Non-Relational

memcached● Use: public website● Used for caching 1000's of serialized objects

per second● Available for 100000's of requests per second

across 1000's of connections● Cache each object only once per site● Supplements a relational database

Alternatives: Redis, TokyoTyrant

Page 85: Relational vs. Non-Relational

“I need to producecomplex summary

reportsover 2TB of data.”

Page 86: Relational vs. Non-Relational

LucidDB“Relational

Column-Store”

Page 87: Relational vs. Non-Relational

LucidDB● For reporting and analysis● Large quantities of data (TB)● Complex OLAP & analytics queries● Business intelligence● compliments a transactional database

Page 88: Relational vs. Non-Relational

“I have 100's ofgovernment documents

I need to serve on the web

and mine for data.”

Page 89: Relational vs. Non-Relational

CouchDB“Document Store”

Page 90: Relational vs. Non-Relational

CouchDB1.CividDB Project2.Storing lots and lots of government documents3.Don't know what's in them4.Don't know how they are structured5.Store them, fi gure out structure later by data

mining.

It's also good for web sites!

Page 91: Relational vs. Non-Relational

“I have a social application andI need to know

who-knows-who-knows-who-knows-

who-knows-who.”

Page 92: Relational vs. Non-Relational

Neo4j“Graph Database”

Page 93: Relational vs. Non-Relational

Neo4j● Social Network Website● 6 degrees of separation● “you may also like”● type and degrees of relationship

Page 94: Relational vs. Non-Relational

“I get 1000's of30K bug reports

per minuteand I need

to mine them for trends.”

Page 95: Relational vs. Non-Relational

Hadoop“Massively Parallel Data Mine”

Page 96: Relational vs. Non-Relational

Hadoop● Massive bug report data feed● 1000's of bug reports per minute● Each bug report 2-45K of data● Need to extract trends and correlate inexact

data● Summarize in daily & weekly reports

Page 97: Relational vs. Non-Relational

Conclusion● Different database systems do better at

different tasks.– every database feature is a tradeoff– no database can do all things well

● Relational vs. non-relational doesn't matter– pick the database(s) for the project or the task

Page 98: Relational vs. Non-Relational

Questions?● PostgreSQL Project

– www.postgresql.org

[email protected]

● PostgreSQL Experts– www.pgexperts.com

● www.pgexperts.com/documents.html● Open Source Database Survey

– Selena Deckleman

– Open Source Database Survey:www.ossdbsurvey.org

● PostgreSQL Boothtrade show fl oor

● PostgreSQL 9.0 BOF, Tonight 7pm

Copyright 2010 Josh Berkus, distributable under the creative commons attribution license,except for 3rd-party images which are property of their respective owners.Special thanks to Selena Deckelman for the bunnies image and for the Open Source Database survey.