Slide 1

Slide 1 text

Introduction Documents Distributed System Queries and Views CouchApps CouchDB Kerstin Puschke The Next Web - Barcamp Salzburg 2011 Kerstin Puschke NoSQL

Slide 2

Slide 2 text

Introduction Documents Distributed System Queries and Views CouchApps License License Creative Commons Attribution 3.0 Germany Lizenz, see http://creativecommons.org/licenses/by/3.0/de/ Kerstin Puschke NoSQL

Slide 3

Slide 3 text

Introduction Documents Distributed System Queries and Views CouchApps Outline 1 Introduction Kerstin Puschke NoSQL

Slide 4

Slide 4 text

Introduction Documents Distributed System Queries and Views CouchApps Outline 1 Introduction 2 Documents Document-Oriented Data Model Updates and Concurrency Design Documents Kerstin Puschke NoSQL

Slide 5

Slide 5 text

Introduction Documents Distributed System Queries and Views CouchApps Outline 1 Introduction 2 Documents Document-Oriented Data Model Updates and Concurrency Design Documents 3 Distributed System Kerstin Puschke NoSQL

Slide 6

Slide 6 text

Introduction Documents Distributed System Queries and Views CouchApps Outline 1 Introduction 2 Documents Document-Oriented Data Model Updates and Concurrency Design Documents 3 Distributed System 4 Queries and Views Views Creating Views with Map Reduce Example Kerstin Puschke NoSQL

Slide 7

Slide 7 text

Introduction Documents Distributed System Queries and Views CouchApps Outline 1 Introduction 2 Documents Document-Oriented Data Model Updates and Concurrency Design Documents 3 Distributed System 4 Queries and Views Views Creating Views with Map Reduce Example 5 CouchApps Kerstin Puschke NoSQL

Slide 8

Slide 8 text

Introduction Documents Distributed System Queries and Views CouchApps CouchDB? Cluster Of Unreliable Commodity Hardware DataBase Kerstin Puschke NoSQL

Slide 9

Slide 9 text

Introduction Documents Distributed System Queries and Views CouchApps CouchDB? Cluster Of Unreliable Commodity Hardware DataBase NoSQL database, non-relational data store Kerstin Puschke NoSQL

Slide 10

Slide 10 text

Introduction Documents Distributed System Queries and Views CouchApps CouchDB? Cluster Of Unreliable Commodity Hardware DataBase NoSQL database, non-relational data store schemaless Kerstin Puschke NoSQL

Slide 11

Slide 11 text

Introduction Documents Distributed System Queries and Views CouchApps CouchDB? Cluster Of Unreliable Commodity Hardware DataBase NoSQL database, non-relational data store schemaless distributed computing - robust replication Kerstin Puschke NoSQL

Slide 12

Slide 12 text

Introduction Documents Distributed System Queries and Views CouchApps CouchDB? Cluster Of Unreliable Commodity Hardware DataBase NoSQL database, non-relational data store schemaless distributed computing - robust replication scaling up and down Kerstin Puschke NoSQL

Slide 13

Slide 13 text

Introduction Documents Distributed System Queries and Views CouchApps CouchDB? Cluster Of Unreliable Commodity Hardware DataBase NoSQL database, non-relational data store schemaless distributed computing - robust replication scaling up and down open web standards Kerstin Puschke NoSQL

Slide 14

Slide 14 text

Introduction Documents Distributed System Queries and Views CouchApps CouchDB? Cluster Of Unreliable Commodity Hardware DataBase NoSQL database, non-relational data store schemaless distributed computing - robust replication scaling up and down open web standards decentralized (web)applications - available offline Kerstin Puschke NoSQL

Slide 15

Slide 15 text

Introduction Documents Distributed System Queries and Views CouchApps In the Wild BBC Kerstin Puschke NoSQL

Slide 16

Slide 16 text

Introduction Documents Distributed System Queries and Views CouchApps In the Wild BBC Ubuntu One Kerstin Puschke NoSQL

Slide 17

Slide 17 text

Introduction Documents Distributed System Queries and Views CouchApps In the Wild BBC Ubuntu One lots of software, websites, facebook apps, . . . Kerstin Puschke NoSQL

Slide 18

Slide 18 text

Introduction Documents Distributed System Queries and Views CouchApps Getting Started RESTful HTTP/JSON API Kerstin Puschke NoSQL

Slide 19

Slide 19 text

Introduction Documents Distributed System Queries and Views CouchApps Getting Started RESTful HTTP/JSON API Webserver included Kerstin Puschke NoSQL

Slide 20

Slide 20 text

Introduction Documents Distributed System Queries and Views CouchApps Getting Started RESTful HTTP/JSON API Webserver included http://localhost:5984 http://localhost:5984/_all_dbs Kerstin Puschke NoSQL

Slide 21

Slide 21 text

Introduction Documents Distributed System Queries and Views CouchApps Getting Started RESTful HTTP/JSON API Webserver included http://localhost:5984 http://localhost:5984/_all_dbs create a database PUT http://localhost:5984/foo Kerstin Puschke NoSQL

Slide 22

Slide 22 text

Introduction Documents Distributed System Queries and Views CouchApps Getting Started RESTful HTTP/JSON API Webserver included http://localhost:5984 http://localhost:5984/_all_dbs create a database PUT http://localhost:5984/foo delete a a database DELETE http://localhost:5984/foo Kerstin Puschke NoSQL

Slide 23

Slide 23 text

Introduction Documents Distributed System Queries and Views CouchApps Getting Started RESTful HTTP/JSON API Webserver included http://localhost:5984 http://localhost:5984/_all_dbs create a database PUT http://localhost:5984/foo delete a a database DELETE http://localhost:5984/foo Webinterface Futon http://localhost:5984/_utils Kerstin Puschke NoSQL

Slide 24

Slide 24 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Document-Oriented Data Model abstraction layer above key-value pairs Kerstin Puschke NoSQL

Slide 25

Slide 25 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Document-Oriented Data Model abstraction layer above key-value pairs document: self-contained data, reasonable unit of information (invoice, business card,. . . ) Kerstin Puschke NoSQL

Slide 26

Slide 26 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Document-Oriented Data Model abstraction layer above key-value pairs document: self-contained data, reasonable unit of information (invoice, business card,. . . ) schemaless, no referential integrity flexible, but dangerous Kerstin Puschke NoSQL

Slide 27

Slide 27 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Document-Oriented Data Model abstraction layer above key-value pairs document: self-contained data, reasonable unit of information (invoice, business card,. . . ) schemaless, no referential integrity flexible, but dangerous JSON-object values can be scalar, array, objects, nested data structures,. . . Kerstin Puschke NoSQL

Slide 28

Slide 28 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Document-Oriented Data Model abstraction layer above key-value pairs document: self-contained data, reasonable unit of information (invoice, business card,. . . ) schemaless, no referential integrity flexible, but dangerous JSON-object values can be scalar, array, objects, nested data structures,. . . mandatory fields: Kerstin Puschke NoSQL

Slide 29

Slide 29 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Document-Oriented Data Model abstraction layer above key-value pairs document: self-contained data, reasonable unit of information (invoice, business card,. . . ) schemaless, no referential integrity flexible, but dangerous JSON-object values can be scalar, array, objects, nested data structures,. . . mandatory fields: unique document identifier _id (UUID) Kerstin Puschke NoSQL

Slide 30

Slide 30 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Document-Oriented Data Model abstraction layer above key-value pairs document: self-contained data, reasonable unit of information (invoice, business card,. . . ) schemaless, no referential integrity flexible, but dangerous JSON-object values can be scalar, array, objects, nested data structures,. . . mandatory fields: unique document identifier _id (UUID) revision identifier _rev Kerstin Puschke NoSQL

Slide 31

Slide 31 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Document-Oriented Data Model abstraction layer above key-value pairs document: self-contained data, reasonable unit of information (invoice, business card,. . . ) schemaless, no referential integrity flexible, but dangerous JSON-object values can be scalar, array, objects, nested data structures,. . . mandatory fields: unique document identifier _id (UUID) revision identifier _rev files can be attached to documents Kerstin Puschke NoSQL

Slide 32

Slide 32 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents CouchDB Document JSON Kerstin Puschke NoSQL

Slide 33

Slide 33 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Updates client sends full document Kerstin Puschke NoSQL

Slide 34

Slide 34 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Updates client sends full document append-only - new version appended to database no diffs, no partial updates Kerstin Puschke NoSQL

Slide 35

Slide 35 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Updates client sends full document append-only - new version appended to database no diffs, no partial updates robust and fast Kerstin Puschke NoSQL

Slide 36

Slide 36 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Multi Version Concurrency Control optimistic locking Kerstin Puschke NoSQL

Slide 37

Slide 37 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Multi Version Concurrency Control optimistic locking client sends new version of document along with old _rev Kerstin Puschke NoSQL

Slide 38

Slide 38 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Multi Version Concurrency Control optimistic locking client sends new version of document along with old _rev server checks if _rev matches the one stored in the database Kerstin Puschke NoSQL

Slide 39

Slide 39 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Multi Version Concurrency Control optimistic locking client sends new version of document along with old _rev server checks if _rev matches the one stored in the database yes: new version saved along with new _rev Kerstin Puschke NoSQL

Slide 40

Slide 40 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Multi Version Concurrency Control optimistic locking client sends new version of document along with old _rev server checks if _rev matches the one stored in the database yes: new version saved along with new _rev no: conflict - update refused with 409 Kerstin Puschke NoSQL

Slide 41

Slide 41 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Multi Version Concurrency Control optimistic locking client sends new version of document along with old _rev server checks if _rev matches the one stored in the database yes: new version saved along with new _rev no: conflict - update refused with 409 no version control some versions unavailable (at least on some nodes) Kerstin Puschke NoSQL

Slide 42

Slide 42 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Design Documents _id starts with _design Kerstin Puschke NoSQL

Slide 43

Slide 43 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Design Documents _id starts with _design create, update, replicate,. . . like any other document Kerstin Puschke NoSQL

Slide 44

Slide 44 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Design Documents _id starts with _design create, update, replicate,. . . like any other document no data but code Kerstin Puschke NoSQL

Slide 45

Slide 45 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Design Documents _id starts with _design create, update, replicate,. . . like any other document no data but code validate_doc_update: validation of updates Kerstin Puschke NoSQL

Slide 46

Slide 46 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Design Documents _id starts with _design create, update, replicate,. . . like any other document no data but code validate_doc_update: validation of updates update: server-side logic for document creation or update Kerstin Puschke NoSQL

Slide 47

Slide 47 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Design Documents _id starts with _design create, update, replicate,. . . like any other document no data but code validate_doc_update: validation of updates update: server-side logic for document creation or update show, list: rendering output Kerstin Puschke NoSQL

Slide 48

Slide 48 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Design Documents _id starts with _design create, update, replicate,. . . like any other document no data but code validate_doc_update: validation of updates update: server-side logic for document creation or update show, list: rendering output map, reduce: creation of views/indices Kerstin Puschke NoSQL

Slide 49

Slide 49 text

Introduction Documents Distributed System Queries and Views CouchApps Document-Oriented Data Model Updates and Concurrency Design Documents Design Documents _id starts with _design create, update, replicate,. . . like any other document no data but code validate_doc_update: validation of updates update: server-side logic for document creation or update show, list: rendering output map, reduce: creation of views/indices default language: JavaScript plugins for PHP, Ruby, Python, Perl, Common Lisp, Erlang,. . . Kerstin Puschke NoSQL

Slide 50

Slide 50 text

Introduction Documents Distributed System Queries and Views CouchApps Replication shared nothing cluster Kerstin Puschke NoSQL

Slide 51

Slide 51 text

Introduction Documents Distributed System Queries and Views CouchApps Replication shared nothing cluster incremental Kerstin Puschke NoSQL

Slide 52

Slide 52 text

Introduction Documents Distributed System Queries and Views CouchApps Replication shared nothing cluster incremental latest revision only - no transfer of previous versions Kerstin Puschke NoSQL

Slide 53

Slide 53 text

Introduction Documents Distributed System Queries and Views CouchApps Replication shared nothing cluster incremental latest revision only - no transfer of previous versions N-Master, Master-Slave,. . . Kerstin Puschke NoSQL

Slide 54

Slide 54 text

Introduction Documents Distributed System Queries and Views CouchApps Replication shared nothing cluster incremental latest revision only - no transfer of previous versions N-Master, Master-Slave,. . . very robust Kerstin Puschke NoSQL

Slide 55

Slide 55 text

Introduction Documents Distributed System Queries and Views CouchApps Replication shared nothing cluster incremental latest revision only - no transfer of previous versions N-Master, Master-Slave,. . . very robust filtered Kerstin Puschke NoSQL

Slide 56

Slide 56 text

Introduction Documents Distributed System Queries and Views CouchApps Replication shared nothing cluster incremental latest revision only - no transfer of previous versions N-Master, Master-Slave,. . . very robust filtered ’non-destructive’ conflict handling Kerstin Puschke NoSQL

Slide 57

Slide 57 text

Introduction Documents Distributed System Queries and Views CouchApps Eventual Consistency Consistency, Availability, Partition Tolerance Consistency, Availability, Partition Tolerance - you can’t have it all. . . Kerstin Puschke NoSQL

Slide 58

Slide 58 text

Introduction Documents Distributed System Queries and Views CouchApps Eventual Consistency Consistency, Availability, Partition Tolerance Consistency, Availability, Partition Tolerance - you can’t have it all. . . CouchDB provides eventual consistency Kerstin Puschke NoSQL

Slide 59

Slide 59 text

Introduction Documents Distributed System Queries and Views CouchApps Eventual Consistency Consistency, Availability, Partition Tolerance Consistency, Availability, Partition Tolerance - you can’t have it all. . . CouchDB provides eventual consistency inconsistency window Kerstin Puschke NoSQL

Slide 60

Slide 60 text

Introduction Documents Distributed System Queries and Views CouchApps Eventual Consistency Consistency, Availability, Partition Tolerance Consistency, Availability, Partition Tolerance - you can’t have it all. . . CouchDB provides eventual consistency inconsistency window BASE - basically available, soft-state, eventually consistent Kerstin Puschke NoSQL

Slide 61

Slide 61 text

Introduction Documents Distributed System Queries and Views CouchApps Eventual Consistency Consistency, Availability, Partition Tolerance Consistency, Availability, Partition Tolerance - you can’t have it all. . . CouchDB provides eventual consistency inconsistency window BASE - basically available, soft-state, eventually consistent ACID on a single node, BASE in a distributed system Kerstin Puschke NoSQL

Slide 62

Slide 62 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Queries fetch document by _id Kerstin Puschke NoSQL

Slide 63

Slide 63 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Queries fetch document by _id no dynamic queries, no ad hoc reporting Kerstin Puschke NoSQL

Slide 64

Slide 64 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Queries fetch document by _id no dynamic queries, no ad hoc reporting need to create views (indices) to query Kerstin Puschke NoSQL

Slide 65

Slide 65 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Views (secondary) index key-value-pairs Kerstin Puschke NoSQL

Slide 66

Slide 66 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Views (secondary) index key-value-pairs keys and values are values from documents Kerstin Puschke NoSQL

Slide 67

Slide 67 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Views (secondary) index key-value-pairs keys and values are values from documents Example: creation date as key, title of post as value Kerstin Puschke NoSQL

Slide 68

Slide 68 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Views (secondary) index key-value-pairs keys and values are values from documents Example: creation date as key, title of post as value composite keys and values possible Kerstin Puschke NoSQL

Slide 69

Slide 69 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Views (secondary) index key-value-pairs keys and values are values from documents Example: creation date as key, title of post as value composite keys and values possible sorted by key Kerstin Puschke NoSQL

Slide 70

Slide 70 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Views (secondary) index key-value-pairs keys and values are values from documents Example: creation date as key, title of post as value composite keys and values possible sorted by key efficient lookup of keys or key ranges ’Posts created in May 2009’ Kerstin Puschke NoSQL

Slide 71

Slide 71 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Views (secondary) index key-value-pairs keys and values are values from documents Example: creation date as key, title of post as value composite keys and values possible sorted by key efficient lookup of keys or key ranges ’Posts created in May 2009’ values can be aggregated Kerstin Puschke NoSQL

Slide 72

Slide 72 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Views (secondary) index key-value-pairs keys and values are values from documents Example: creation date as key, title of post as value composite keys and values possible sorted by key efficient lookup of keys or key ranges ’Posts created in May 2009’ values can be aggregated created and updated when accessed Kerstin Puschke NoSQL

Slide 73

Slide 73 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example View Example View with key date and value title, in Futon Kerstin Puschke NoSQL

Slide 74

Slide 74 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Map Reduce map and reduce functions common in functional programming Kerstin Puschke NoSQL

Slide 75

Slide 75 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Map Reduce map and reduce functions common in functional programming MapReduce: framework for concurrent, distributed processing of large data sets (Google) Kerstin Puschke NoSQL

Slide 76

Slide 76 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Map Reduce map and reduce functions common in functional programming MapReduce: framework for concurrent, distributed processing of large data sets (Google) map and reduce defined in design documents Kerstin Puschke NoSQL

Slide 77

Slide 77 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Map Reduce map and reduce functions common in functional programming MapReduce: framework for concurrent, distributed processing of large data sets (Google) map and reduce defined in design documents map Kerstin Puschke NoSQL

Slide 78

Slide 78 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Map Reduce map and reduce functions common in functional programming MapReduce: framework for concurrent, distributed processing of large data sets (Google) map and reduce defined in design documents map input: one document Kerstin Puschke NoSQL

Slide 79

Slide 79 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Map Reduce map and reduce functions common in functional programming MapReduce: framework for concurrent, distributed processing of large data sets (Google) map and reduce defined in design documents map input: one document computes key-value pairs for view Kerstin Puschke NoSQL

Slide 80

Slide 80 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Map Reduce map and reduce functions common in functional programming MapReduce: framework for concurrent, distributed processing of large data sets (Google) map and reduce defined in design documents map input: one document computes key-value pairs for view sorted by key Kerstin Puschke NoSQL

Slide 81

Slide 81 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Map Reduce map and reduce functions common in functional programming MapReduce: framework for concurrent, distributed processing of large data sets (Google) map and reduce defined in design documents map input: one document computes key-value pairs for view sorted by key reduce (optional) Kerstin Puschke NoSQL

Slide 82

Slide 82 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Map Reduce map and reduce functions common in functional programming MapReduce: framework for concurrent, distributed processing of large data sets (Google) map and reduce defined in design documents map input: one document computes key-value pairs for view sorted by key reduce (optional) input: (partial) results of map or of previous calls to reduce Kerstin Puschke NoSQL

Slide 83

Slide 83 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Map Reduce map and reduce functions common in functional programming MapReduce: framework for concurrent, distributed processing of large data sets (Google) map and reduce defined in design documents map input: one document computes key-value pairs for view sorted by key reduce (optional) input: (partial) results of map or of previous calls to reduce returns aggregated values Kerstin Puschke NoSQL

Slide 84

Slide 84 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Map Function Example Design doc with map Kerstin Puschke NoSQL

Slide 85

Slide 85 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Reduce Function Example Design doc with map and reduce Kerstin Puschke NoSQL

Slide 86

Slide 86 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Querying View Example View without reduce Kerstin Puschke NoSQL

Slide 87

Slide 87 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Querying a View Example View with reduce Kerstin Puschke NoSQL

Slide 88

Slide 88 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Querying a View Example View with reduce View with reduce and group_level=2 Kerstin Puschke NoSQL

Slide 89

Slide 89 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Example Blogpost with “inline” comments Kerstin Puschke NoSQL

Slide 90

Slide 90 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Example Posts and Comments in different docs Kerstin Puschke NoSQL

Slide 91

Slide 91 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Example View to query for posts and their comments map-function with composite key function(doc) { if (doc.type == "post") { emit([doc._id, 0], doc); } else if (doc.type == "comment") { emit([doc.post_id, 1], doc); } } Kerstin Puschke NoSQL

Slide 92

Slide 92 text

Introduction Documents Distributed System Queries and Views CouchApps Views Creating Views with Map Reduce Example Example contd. Kerstin Puschke NoSQL

Slide 93

Slide 93 text

Introduction Documents Distributed System Queries and Views CouchApps CouchApps applications living in the database Kerstin Puschke NoSQL

Slide 94

Slide 94 text

Introduction Documents Distributed System Queries and Views CouchApps CouchApps applications living in the database no middleware Kerstin Puschke NoSQL

Slide 95

Slide 95 text

Introduction Documents Distributed System Queries and Views CouchApps CouchApps applications living in the database no middleware data and code are documents: update, fork, backup etc. via replication Kerstin Puschke NoSQL

Slide 96

Slide 96 text

Introduction Documents Distributed System Queries and Views CouchApps CouchApps applications living in the database no middleware data and code are documents: update, fork, backup etc. via replication show/list functions, direct access to attachments (HTML,JavaScript,. . . ) Kerstin Puschke NoSQL

Slide 97

Slide 97 text

Introduction Documents Distributed System Queries and Views CouchApps CouchApps applications living in the database no middleware data and code are documents: update, fork, backup etc. via replication show/list functions, direct access to attachments (HTML,JavaScript,. . . ) load data via AJAX Kerstin Puschke NoSQL

Slide 98

Slide 98 text

Introduction Documents Distributed System Queries and Views CouchApps Q & A Thanks for listening! Questions? Comments? Kerstin Puschke NoSQL

Slide 99

Slide 99 text

Links The CouchDB Project http://couchdb.apache.org Kerstin Puschke NoSQL

Slide 100

Slide 100 text

Links The CouchDB Project http://couchdb.apache.org CouchDB Wiki http://wiki.apache.org/couchdb Kerstin Puschke NoSQL

Slide 101

Slide 101 text

Links The CouchDB Project http://couchdb.apache.org CouchDB Wiki http://wiki.apache.org/couchdb Book: CouchDB - The Definitive Guide http://guide.couchdb.org Kerstin Puschke NoSQL

Slide 102

Slide 102 text

Links The CouchDB Project http://couchdb.apache.org CouchDB Wiki http://wiki.apache.org/couchdb Book: CouchDB - The Definitive Guide http://guide.couchdb.org CouchApp - framework: Simple JavaScript applications with CouchDB http://couchapp.org Kerstin Puschke NoSQL

Slide 103

Slide 103 text

Links The CouchDB Project http://couchdb.apache.org CouchDB Wiki http://wiki.apache.org/couchdb Book: CouchDB - The Definitive Guide http://guide.couchdb.org CouchApp - framework: Simple JavaScript applications with CouchDB http://couchapp.org Couchbase - free hosting, docs, and more http://www.couchone.com Kerstin Puschke NoSQL