161
CouchDB: the last RESTful JSON service you’ll ever need Carlo Cabanilla

CouchDB: the last RESTful JSON store you'll ever need

Embed Size (px)

Citation preview

Page 1: CouchDB: the last RESTful JSON store you'll ever need

CouchDB: the last RESTful JSON service you’ll ever needCarlo Cabanilla

Page 2: CouchDB: the last RESTful JSON store you'll ever need

CouchDB is a RESTful JSON store

Page 3: CouchDB: the last RESTful JSON store you'll ever need

CouchDB is a RESTful JSON store

Page 4: CouchDB: the last RESTful JSON store you'll ever need

Create

Page 5: CouchDB: the last RESTful JSON store you'll ever need

> PUT /mydb/stuff> Content-type: application/json>> {"thing_count":1}

Create

Page 6: CouchDB: the last RESTful JSON store you'll ever need

> PUT /mydb/stuff> Content-type: application/json>> {"thing_count":1}

< HTTP/1.1 201 Created<< {"_id":"stuff", < "_rev":"1-e86a94c1...", < "thing_count":1}

Create

Page 7: CouchDB: the last RESTful JSON store you'll ever need

Read

Page 8: CouchDB: the last RESTful JSON store you'll ever need

> GET /mydb/stuff

Read

Page 9: CouchDB: the last RESTful JSON store you'll ever need

> GET /mydb/stuff

< HTTP/1.1 200 OK<< {"_id":"stuff", < "_rev":"1-e86a94c1...", < "thing_count":1}

Read

Page 10: CouchDB: the last RESTful JSON store you'll ever need

Update

Page 11: CouchDB: the last RESTful JSON store you'll ever need

> PUT /mydb/stuff> Content-type: application/json>> {"_id":"stuff", > "_rev":"1-e86a94c1...", > "thing_count":13}

Update

Page 12: CouchDB: the last RESTful JSON store you'll ever need

> PUT /mydb/stuff> Content-type: application/json>> {"_id":"stuff", > "_rev":"1-e86a94c1...", > "thing_count":13}

Update

< HTTP/1.1 201 Created<< {"_id":"stuff", < "_rev":"2-39a9bf12...", < "thing_count":13}

Page 13: CouchDB: the last RESTful JSON store you'll ever need

Delete

Page 14: CouchDB: the last RESTful JSON store you'll ever need

> DELETE /mydb/stuff?rev=2-39a9bf12...

Delete

Page 15: CouchDB: the last RESTful JSON store you'll ever need

> DELETE /mydb/stuff?rev=2-39a9bf12...

Delete

< HTTP/1.1 200 OK

Page 16: CouchDB: the last RESTful JSON store you'll ever need

a RESTful JSON store

Page 17: CouchDB: the last RESTful JSON store you'll ever need

a RESTful JSON store

Page 18: CouchDB: the last RESTful JSON store you'll ever need

PUT /look/ma/im/doing/rest

Page 19: CouchDB: the last RESTful JSON store you'll ever need

PUT /look/ma/im/doing/rest

Do you support Conditional GET?

Page 20: CouchDB: the last RESTful JSON store you'll ever need

Conditional GET is the

holy grail of

REST

Page 21: CouchDB: the last RESTful JSON store you'll ever need

Conditional GET is the holy grail of REST

Page 22: CouchDB: the last RESTful JSON store you'll ever need

> GET /that/money

Conditional GET is the holy grail of REST

Page 23: CouchDB: the last RESTful JSON store you'll ever need

> GET /that/money

< HTTP/1.1 200 OK<< {“that_money”: “$5”}

Conditional GET is the holy grail of REST

Page 24: CouchDB: the last RESTful JSON store you'll ever need

Conditional GET is the holy grail of REST

Page 25: CouchDB: the last RESTful JSON store you'll ever need

> GET /that/money

Conditional GET is the holy grail of REST

Page 26: CouchDB: the last RESTful JSON store you'll ever need

> GET /that/money

(wait for a few ms)

Conditional GET is the holy grail of REST

Page 27: CouchDB: the last RESTful JSON store you'll ever need

> GET /that/money

< HTTP/1.1 200 OK<< {“that_money”: “$5”}

(wait for a few ms)

Conditional GET is the holy grail of REST

Page 28: CouchDB: the last RESTful JSON store you'll ever need

( )> GET /that/money

< HTTP/1.1 200 OK<< {“that_money”: “$5”}

(wait for a few ms)

x 1,000,000

Conditional GET is the holy grail of REST

Page 29: CouchDB: the last RESTful JSON store you'll ever need

( )> GET /that/money

< HTTP/1.1 200 OK<< {“that_money”: “$5”}

(wait for a few ms)

x 1,000,000 = slow!

Conditional GET is the holy grail of REST

Page 30: CouchDB: the last RESTful JSON store you'll ever need

Conditional GET is the holy grail of REST

Page 31: CouchDB: the last RESTful JSON store you'll ever need

> GET /that/money

Conditional GET is the holy grail of REST

Page 32: CouchDB: the last RESTful JSON store you'll ever need

> GET /that/money

(Uncached: slow)

Conditional GET is the holy grail of REST

Page 33: CouchDB: the last RESTful JSON store you'll ever need

> GET /that/money

< HTTP/1.1 200 OK< Etag: "1-24c87859"<< {“that_money”: “$5”}

(Uncached: slow)

Conditional GET is the holy grail of REST

Page 34: CouchDB: the last RESTful JSON store you'll ever need

> GET /that/money

< HTTP/1.1 200 OK< Etag: "1-24c87859"<< {“that_money”: “$5”}

(Uncached: slow)

Conditional GET is the holy grail of REST

Page 35: CouchDB: the last RESTful JSON store you'll ever need

Conditional GET is the holy grail of REST

Page 36: CouchDB: the last RESTful JSON store you'll ever need

> GET /that/money> If-None-Match: "1-24c87859"

Conditional GET is the holy grail of REST

Page 37: CouchDB: the last RESTful JSON store you'll ever need

> GET /that/money> If-None-Match: "1-24c87859"

Conditional GET is the holy grail of REST

Page 38: CouchDB: the last RESTful JSON store you'll ever need

> GET /that/money> If-None-Match: "1-24c87859"

(Cache hit: fast)

Conditional GET is the holy grail of REST

Page 39: CouchDB: the last RESTful JSON store you'll ever need

> GET /that/money> If-None-Match: "1-24c87859"

< HTTP/1.1 304 Not Modified< Etag: "1-24c87859"< Content-Length: 0

(Cache hit: fast)

Conditional GET is the holy grail of REST

Page 40: CouchDB: the last RESTful JSON store you'll ever need

Conditional GET is the holy grail of REST

Page 41: CouchDB: the last RESTful JSON store you'll ever need

> GET /that/money> If-None-Match: "1-24c87859"

Conditional GET is the holy grail of REST

Page 42: CouchDB: the last RESTful JSON store you'll ever need

> GET /that/money> If-None-Match: "1-24c87859"

(Data changed so cache miss )

Conditional GET is the holy grail of REST

Page 43: CouchDB: the last RESTful JSON store you'll ever need

> GET /that/money> If-None-Match: "1-24c87859"

< HTTP/1.1 200 Ok< Etag: "2-535d9fb2"< < {“that_money”: “$1,000,000”}

(Data changed so cache miss )

Conditional GET is the holy grail of REST

Page 44: CouchDB: the last RESTful JSON store you'll ever need

a RESTful JSON store

Page 45: CouchDB: the last RESTful JSON store you'll ever need

a RESTful JSON store

Page 46: CouchDB: the last RESTful JSON store you'll ever need
Page 47: CouchDB: the last RESTful JSON store you'll ever need

GET /my_db/some_id

Page 48: CouchDB: the last RESTful JSON store you'll ever need

GET /my_db/some_id

{

Page 49: CouchDB: the last RESTful JSON store you'll ever need

GET /my_db/some_id

{ "_id": "some_id",

Page 50: CouchDB: the last RESTful JSON store you'll ever need

GET /my_db/some_id

{ "_id": "some_id", "_rev": "1-24c8785964763c21d...",

Page 51: CouchDB: the last RESTful JSON store you'll ever need

GET /my_db/some_id

{ "_id": "some_id", "_rev": "1-24c8785964763c21d...", "my_field1": "json does strings",

Page 52: CouchDB: the last RESTful JSON store you'll ever need

GET /my_db/some_id

{ "_id": "some_id", "_rev": "1-24c8785964763c21d...", "my_field1": "json does strings", "numbers too": 123.12,

Page 53: CouchDB: the last RESTful JSON store you'll ever need

GET /my_db/some_id

{ "_id": "some_id", "_rev": "1-24c8785964763c21d...", "my_field1": "json does strings", "numbers too": 123.12, "and arrays": ["ain't", "it", "cool?"],

Page 54: CouchDB: the last RESTful JSON store you'll ever need

GET /my_db/some_id

{ "_id": "some_id", "_rev": "1-24c8785964763c21d...", "my_field1": "json does strings", "numbers too": 123.12, "and arrays": ["ain't", "it", "cool?"], "dicts too!": { "don't":"try",

Page 55: CouchDB: the last RESTful JSON store you'll ever need

GET /my_db/some_id

{ "_id": "some_id", "_rev": "1-24c8785964763c21d...", "my_field1": "json does strings", "numbers too": 123.12, "and arrays": ["ain't", "it", "cool?"], "dicts too!": { "don't":"try", "this":"in",

Page 56: CouchDB: the last RESTful JSON store you'll ever need

GET /my_db/some_id

{ "_id": "some_id", "_rev": "1-24c8785964763c21d...", "my_field1": "json does strings", "numbers too": 123.12, "and arrays": ["ain't", "it", "cool?"], "dicts too!": { "don't":"try", "this":"in", "Oracle!":null }

Page 57: CouchDB: the last RESTful JSON store you'll ever need

GET /my_db/some_id

{ "_id": "some_id", "_rev": "1-24c8785964763c21d...", "my_field1": "json does strings", "numbers too": 123.12, "and arrays": ["ain't", "it", "cool?"], "dicts too!": { "don't":"try", "this":"in", "Oracle!":null }}

Page 58: CouchDB: the last RESTful JSON store you'll ever need

Schema-less

Page 59: CouchDB: the last RESTful JSON store you'll ever need

How do I know what a document means??

Page 60: CouchDB: the last RESTful JSON store you'll ever need

Duck-type your database

Page 61: CouchDB: the last RESTful JSON store you'll ever need

Duck-type your database

Duck-typing

Page 62: CouchDB: the last RESTful JSON store you'll ever need

def document_factory(doc):

Duck-type your database

Duck-typing

Page 63: CouchDB: the last RESTful JSON store you'll ever need

def document_factory(doc): if doc['look'] == Duck.look()

Duck-type your database

Duck-typing

Page 64: CouchDB: the last RESTful JSON store you'll ever need

def document_factory(doc): if doc['look'] == Duck.look() and doc['swim'] == Duck.swim()

Duck-type your database

Duck-typing

Page 65: CouchDB: the last RESTful JSON store you'll ever need

def document_factory(doc): if doc['look'] == Duck.look() and doc['swim'] == Duck.swim() and doc['quack'] == Duck.quack():

Duck-type your database

Duck-typing

Page 66: CouchDB: the last RESTful JSON store you'll ever need

def document_factory(doc): if doc['look'] == Duck.look() and doc['swim'] == Duck.swim() and doc['quack'] == Duck.quack(): return Duck(doc)

Duck-type your database

Duck-typing

Page 67: CouchDB: the last RESTful JSON store you'll ever need

Duck-type your database

Python

Page 68: CouchDB: the last RESTful JSON store you'll ever need

def document_factory(doc):

Duck-type your database

Python

Page 69: CouchDB: the last RESTful JSON store you'll ever need

def document_factory(doc): if doc['type'] == 'Duck':

Duck-type your database

Python

Page 70: CouchDB: the last RESTful JSON store you'll ever need

def document_factory(doc): if doc['type'] == 'Duck': return Duck(doc)

Duck-type your database

Python

Page 71: CouchDB: the last RESTful JSON store you'll ever need

def document_factory(doc): if doc['type'] == 'Duck': return Duck(doc) elif doc['type'] == 'Dog':

Duck-type your database

Python

Page 72: CouchDB: the last RESTful JSON store you'll ever need

def document_factory(doc): if doc['type'] == 'Duck': return Duck(doc) elif doc['type'] == 'Dog': return Dog(doc)

Duck-type your database

Python

Page 73: CouchDB: the last RESTful JSON store you'll ever need

def document_factory(doc): if doc['type'] == 'Duck': return Duck(doc) elif doc['type'] == 'Dog': return Dog(doc) elif ...:

Duck-type your database

Python

Page 74: CouchDB: the last RESTful JSON store you'll ever need

def document_factory(doc): if doc['type'] == 'Duck': return Duck(doc) elif doc['type'] == 'Dog': return Dog(doc) elif ...: ...

Duck-type your database

Python

Page 75: CouchDB: the last RESTful JSON store you'll ever need

def document_factory(doc): if doc['type'] == 'Duck': return Duck(doc) elif doc['type'] == 'Dog': return Dog(doc) elif ...: ... else:

Duck-type your database

Python

Page 76: CouchDB: the last RESTful JSON store you'll ever need

def document_factory(doc): if doc['type'] == 'Duck': return Duck(doc) elif doc['type'] == 'Dog': return Dog(doc) elif ...: ... else: return GenericDocument(doc)

Duck-type your database

Python

Page 77: CouchDB: the last RESTful JSON store you'll ever need

Duck-type your database

Python

Page 78: CouchDB: the last RESTful JSON store you'll ever need

def document_factory(doc):

Duck-type your database

Python

Page 79: CouchDB: the last RESTful JSON store you'll ever need

def document_factory(doc): import document_types

Duck-type your database

Python

Page 80: CouchDB: the last RESTful JSON store you'll ever need

def document_factory(doc): import document_types doc_class = getattr(doc, doc['type'],

Duck-type your database

Python

Page 81: CouchDB: the last RESTful JSON store you'll ever need

def document_factory(doc): import document_types doc_class = getattr(doc, doc['type'], 'GenericDocument')

Duck-type your database

Python

Page 82: CouchDB: the last RESTful JSON store you'll ever need

def document_factory(doc): import document_types doc_class = getattr(doc, doc['type'], 'GenericDocument') return doc_class(doc)

Duck-type your database

Python

Page 83: CouchDB: the last RESTful JSON store you'll ever need

Duck-type your database

Java

Page 84: CouchDB: the last RESTful JSON store you'll ever need

public static CouchObj documentFactory(CouchDoc doc) {

Duck-type your database

Java

Page 85: CouchDB: the last RESTful JSON store you'll ever need

public static CouchObj documentFactory(CouchDoc doc) { ClassLoader loader = CouchObj.class.getClassLoader();

Duck-type your database

Java

Page 86: CouchDB: the last RESTful JSON store you'll ever need

public static CouchObj documentFactory(CouchDoc doc) { ClassLoader loader = CouchObj.class.getClassLoader(); dispatcherClass = loader.loadClass(doc.get("type"));

Duck-type your database

Java

Page 87: CouchDB: the last RESTful JSON store you'll ever need

public static CouchObj documentFactory(CouchDoc doc) { ClassLoader loader = CouchObj.class.getClassLoader(); dispatcherClass = loader.loadClass(doc.get("type")); return (CouchObj) dispatcherClass.newInstance(doc);

Duck-type your database

Java

Page 88: CouchDB: the last RESTful JSON store you'll ever need

public static CouchObj documentFactory(CouchDoc doc) { ClassLoader loader = CouchObj.class.getClassLoader(); dispatcherClass = loader.loadClass(doc.get("type")); return (CouchObj) dispatcherClass.newInstance(doc);}

Duck-type your database

Java

Page 89: CouchDB: the last RESTful JSON store you'll ever need

That’s silly. How do I query something that has no schema?

Page 90: CouchDB: the last RESTful JSON store you'll ever need

That’s silly. How do I query something that has no schema?

Page 91: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

What the heck is map reduce (in CouchDB)?

Page 92: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

What the heck is map reduce (in CouchDB)?

map reduce ≈ programmatically building an index

Page 93: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

Page 94: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

In CouchDB, a map/reduce pair is called a view.

Page 95: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

In CouchDB, a map/reduce pair is called a view.(different from a RDBMS view!)

Page 96: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

In CouchDB, a map/reduce pair is called a view.(different from a RDBMS view!)

On creation => full database scan then cacheOn db write => incrementally update the cache

Page 97: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

In CouchDB, a map/reduce pair is called a view.(different from a RDBMS view!)

On creation => full database scan then cacheOn db write => incrementally update the cache

(different from Hadoop map reduce!)

Page 98: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

Page 99: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

You can tell CouchDB to store any data in the view

Page 100: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

You can tell CouchDB to store any data in the view(RDBMSs only store indexed values and row ids)

Page 101: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

You can tell CouchDB to store any data in the view(RDBMSs only store indexed values and row ids)

CouchDB view ≈ RDBMS index + materialized view

Page 102: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

Yo, data structures nerds,

Page 103: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

Yo, data structures nerds,

a CouchDB view is a B+ tree

Page 104: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

Yo, data structures nerds,

a CouchDB view is a B+ treemap function determines how keys map to values

Page 105: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

Yo, data structures nerds,

a CouchDB view is a B+ treemap function determines how keys map to values

keys are stored in sorted order

Page 106: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

Yo, data structures nerds,

a CouchDB view is a B+ treemap function determines how keys map to values

keys are stored in sorted order

O(log n) for reads, writes, deletes and range queries

Page 107: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

Yo, data structures nerds,

a CouchDB view is a B+ treemap function determines how keys map to values

keys are stored in sorted order

O(log n) for reads, writes, deletes and range queries

keys are stored close to values

Page 108: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

Page 109: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

For example:

Create an view called people on the names of all person documents.

Page 110: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

function map(doc) { if (doc['type'] == 'person') { emit(doc['name'], doc); }}

For example:

Create an view called people on the names of all person documents.

Page 111: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

function map(doc) { if (doc['type'] == 'person') { emit(doc['name'], doc); }}

function reduce(keys, values) { return values.length; }

For example:

Create an view called people on the names of all person documents.

Page 112: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

Page 113: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

SELECT count(*) FROM people

Page 114: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

SELECT count(*) FROM people

GET /people

Page 115: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

SELECT name, count(*) FROM people GROUP BY name ORDER BY name ASC

SELECT count(*) FROM people

GET /people

Page 116: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

SELECT name, count(*) FROM people GROUP BY name ORDER BY name ASC

GET /people?group=true

SELECT count(*) FROM people

GET /people

Page 117: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

SELECT name, count(*) FROM people GROUP BY name ORDER BY name ASC

GET /people?group=true

SELECT count(*) FROM people

GET /people

SELECT * FROM people ORDER BY name ASC

Page 118: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

SELECT name, count(*) FROM people GROUP BY name ORDER BY name ASC

GET /people?group=true

SELECT count(*) FROM people

GET /people

SELECT * FROM people ORDER BY name ASC

GET /people?reduce=false

Page 119: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

Page 120: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

SELECT * FROM people WHERE name = “bjorn”

Page 121: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

SELECT * FROM people WHERE name = “bjorn”

GET /people?reduce=false&key=”bjorn”

Page 122: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

SELECT * FROM people WHERE name = “bjorn”

GET /people?reduce=false&key=”bjorn”

SELECT * FROM ( SELECT p.*, rownum rn FROM people p ORDER BY name ASC) WHERE rn BETWEEN 50 AND 60

Page 123: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

SELECT * FROM people WHERE name = “bjorn”

GET /people?reduce=false&key=”bjorn”

SELECT * FROM ( SELECT p.*, rownum rn FROM people p ORDER BY name ASC) WHERE rn BETWEEN 50 AND 60

GET /people?reduce=false&limit=10&skip=50

Page 124: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

What about joins??????

Page 125: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

Page 126: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

j/k.

Joins will be in version 0.11 (trunk)

Page 127: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

j/k.

Joins will be in version 0.11 (trunk)

function map(doc) { for (i in doc['comment_ids']) { var comment_id = doc['comment_ids'][i]; emit(doc['_id'], {'_id': comment_id }); }}

Page 128: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

[ {'_id': 1, 'comment_ids': [3, 4]}, {'_id': 2, 'comment_ids': [5]}, {'_id': 3, 'text': 'whoa'}, {'_id': 4, 'text': 'omg'}, {'_id': 5, 'text': 'ponies'}]

Documents in my blog db

Page 129: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

[ {'_id': 1, 'comment_ids': [3, 4]}, {'_id': 2, 'comment_ids': [5]}, {'_id': 3, 'text': 'whoa'}, {'_id': 4, 'text': 'omg'}, {'_id': 5, 'text': 'ponies'}]

Documents in my blog db

GET /myblog/comments? reduce=false&include_docs=true

Page 130: CouchDB: the last RESTful JSON store you'll ever need

You write a map reduce function in Javascript!

[ {'_id': 1, 'comment_ids': [3, 4]}, {'_id': 2, 'comment_ids': [5]}, {'_id': 3, 'text': 'whoa'}, {'_id': 4, 'text': 'omg'}, {'_id': 5, 'text': 'ponies'}]

Documents in my blog db

GET /myblog/comments? reduce=false&include_docs=true

[ {'key': 1, 'value': {'_id': 3, 'text': 'whoa'}}, {'key': 1, 'value': {'_id': 4, 'text': 'omg'}}, {'key': 5, 'value': {'_id': 5, 'text': 'ponies'}}]

Page 131: CouchDB: the last RESTful JSON store you'll ever need

Ok great, so it can pretty much do what a RDBMS can do.

Page 132: CouchDB: the last RESTful JSON store you'll ever need

Ok great, so it can pretty much do what a RDBMS can do.

Why not just use a RDBMS?

Page 133: CouchDB: the last RESTful JSON store you'll ever need

The real question you should be asking yourself is:

Page 134: CouchDB: the last RESTful JSON store you'll ever need

Why keep rewriting HTTP protocol semantics and data object accessorsto front your RDBMS?

The real question you should be asking yourself is:

Page 135: CouchDB: the last RESTful JSON store you'll ever need
Page 136: CouchDB: the last RESTful JSON store you'll ever need
Page 137: CouchDB: the last RESTful JSON store you'll ever need

Middle tier-less web apps!(well, kind of)

Page 138: CouchDB: the last RESTful JSON store you'll ever need

No, forreals,

Page 139: CouchDB: the last RESTful JSON store you'll ever need

No, forreals,

Why not just use a RDBMS?

Page 140: CouchDB: the last RESTful JSON store you'll ever need

ORACLE

Page 141: CouchDB: the last RESTful JSON store you'll ever need

OMGReallyAsininelyCostlyLicencingExpenses

ORACLE

Page 142: CouchDB: the last RESTful JSON store you'll ever need

ClusterOf Unreliable Commodity Hardware DataBase

Page 143: CouchDB: the last RESTful JSON store you'll ever need

ClusterOf Unreliable Commodity Hardware DataBase

?

Page 144: CouchDB: the last RESTful JSON store you'll ever need

Cluster?

Replication!

Page 145: CouchDB: the last RESTful JSON store you'll ever need

Cluster?

Replication!

Incremental,

Page 146: CouchDB: the last RESTful JSON store you'll ever need

Cluster?

Replication!

Incremental,Fault Tolerant,

Page 147: CouchDB: the last RESTful JSON store you'll ever need

Cluster?

Replication!

Incremental,Fault Tolerant,Over HTTP

Page 148: CouchDB: the last RESTful JSON store you'll ever need

replication is expensive

Page 149: CouchDB: the last RESTful JSON store you'll ever need

Mmm, yeah how much did we pay for the LSB?

replication is expensive

Page 150: CouchDB: the last RESTful JSON store you'll ever need

Mmm, yeah how much did we pay for the LSB?

replication is expensive

Seems to work well tho(fingers crossed)

Page 151: CouchDB: the last RESTful JSON store you'll ever need

Postgres replication is . . . ?

Page 152: CouchDB: the last RESTful JSON store you'll ever need

No native replication support yet (coming in v9.0)

Postgres replication is . . . ?

Page 153: CouchDB: the last RESTful JSON store you'll ever need

No native replication support yet (coming in v9.0)

Postgres replication is . . . ?

3rd party solutions are trigger-based (yuck)

Page 154: CouchDB: the last RESTful JSON store you'll ever need

Replication!

Managing replication conflicts (abends)

Page 155: CouchDB: the last RESTful JSON store you'll ever need

Replication!

Managing replication conflicts (abends)

Deterministically pick a version to “win”

Page 156: CouchDB: the last RESTful JSON store you'll ever need

Replication!

Managing replication conflicts (abends)

Deterministically pick a version to “win”

Add a “\_conflict” property to the document

Page 157: CouchDB: the last RESTful JSON store you'll ever need

Replication!

Managing replication conflicts (abends)

Deterministically pick a version to “win”

Add a “\_conflict” property to the document

App must resolve the conflict

Page 158: CouchDB: the last RESTful JSON store you'll ever need

Replication!

Managing replication conflicts (abends)

Much better explanation here:http://books.couchdb.org/relax/reference/conflict-management

Deterministically pick a version to “win”

Add a “\_conflict” property to the document

App must resolve the conflict

Page 159: CouchDB: the last RESTful JSON store you'll ever need

Let’s see some appz!

Page 160: CouchDB: the last RESTful JSON store you'll ever need

• Design philosophy

• Transforming views with list functions

• Lucene integration

• Performance benchmarks

• Erlang under the hood

• Many to many relationships

• Changes feed

• Potential applications at WGen

• Elaborate on middle tier-less web apps

Not enough time :(

Page 161: CouchDB: the last RESTful JSON store you'll ever need

http://couchdb.apache.org/