SlideShare a Scribd company logo
1 of 103
Download to read offline
Introduction
                Documents
       Distributed System
       Queries and Views
               CouchApps




                  CouchDB

              Kerstin Puschke


The Next Web - Barcamp Salzburg 2011




         Kerstin Puschke      NoSQL
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
Introduction
                              Documents
                     Distributed System
                     Queries and Views
                             CouchApps


Outline
  1   Introduction




                       Kerstin Puschke      NoSQL
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
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
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
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
Introduction
                          Documents
                 Distributed System
                 Queries and Views
                         CouchApps


CouchDB?


    Cluster Of Unreliable Commodity Hardware DataBase




                   Kerstin Puschke      NoSQL
Introduction
                           Documents
                  Distributed System
                  Queries and Views
                          CouchApps


CouchDB?


    Cluster Of Unreliable Commodity Hardware DataBase
    NoSQL database, non-relational data store




                    Kerstin Puschke      NoSQL
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
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
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
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
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
Introduction
                       Documents
              Distributed System
              Queries and Views
                      CouchApps


In the Wild




      BBC




                Kerstin Puschke      NoSQL
Introduction
                            Documents
                   Distributed System
                   Queries and Views
                           CouchApps


In the Wild




      BBC
      Ubuntu One




                     Kerstin Puschke      NoSQL
Introduction
                               Documents
                      Distributed System
                      Queries and Views
                              CouchApps


In the Wild




      BBC
      Ubuntu One
      lots of software, websites, facebook apps, . . .




                        Kerstin Puschke      NoSQL
Introduction
                           Documents
                  Distributed System
                  Queries and Views
                          CouchApps


Getting Started


     RESTful HTTP/JSON API




                    Kerstin Puschke      NoSQL
Introduction
                           Documents
                  Distributed System
                  Queries and Views
                          CouchApps


Getting Started


     RESTful HTTP/JSON API
     Webserver included




                    Kerstin Puschke      NoSQL
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
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
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
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
Introduction
                             Documents     Document-Oriented Data Model
                    Distributed System     Updates and Concurrency
                    Queries and Views      Design Documents
                            CouchApps


Document-Oriented Data Model

     abstraction layer above key-value pairs




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


Document-Oriented Data Model

     abstraction layer above key-value pairs
     document: self-contained data, reasonable unit of
     information (invoice, business card,. . . )




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


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
Introduction
                             Documents     Document-Oriented Data Model
                    Distributed System     Updates and Concurrency
                    Queries and Views      Design Documents
                            CouchApps


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
Introduction
                             Documents     Document-Oriented Data Model
                    Distributed System     Updates and Concurrency
                    Queries and Views      Design Documents
                            CouchApps


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
Introduction
                             Documents     Document-Oriented Data Model
                    Distributed System     Updates and Concurrency
                    Queries and Views      Design Documents
                            CouchApps


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
Introduction
                             Documents     Document-Oriented Data Model
                    Distributed System     Updates and Concurrency
                    Queries and Views      Design Documents
                            CouchApps


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
Introduction
                             Documents     Document-Oriented Data Model
                    Distributed System     Updates and Concurrency
                    Queries and Views      Design Documents
                            CouchApps


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
Introduction
                      Documents     Document-Oriented Data Model
             Distributed System     Updates and Concurrency
             Queries and Views      Design Documents
                     CouchApps


CouchDB Document
JSON




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


Updates




    client sends full document




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


Updates




    client sends full document
    append-only - new version appended to database
    no diffs, no partial updates




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


Updates




    client sends full document
    append-only - new version appended to database
    no diffs, no partial updates
    robust and fast




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


Multi Version Concurrency Control


     optimistic locking




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


Multi Version Concurrency Control


     optimistic locking
         client sends new version of document along with old _rev




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


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
Introduction
                             Documents     Document-Oriented Data Model
                    Distributed System     Updates and Concurrency
                    Queries and Views      Design Documents
                            CouchApps


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
Introduction
                             Documents     Document-Oriented Data Model
                    Distributed System     Updates and Concurrency
                    Queries and Views      Design Documents
                            CouchApps


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
Introduction
                             Documents     Document-Oriented Data Model
                    Distributed System     Updates and Concurrency
                    Queries and Views      Design Documents
                            CouchApps


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
Introduction
                          Documents     Document-Oriented Data Model
                 Distributed System     Updates and Concurrency
                 Queries and Views      Design Documents
                         CouchApps


Design Documents


    _id starts with _design




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


Design Documents


    _id starts with _design
    create, update, replicate,. . . like any other document




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


Design Documents


    _id starts with _design
    create, update, replicate,. . . like any other document
    no data but code




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


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
Introduction
                             Documents     Document-Oriented Data Model
                    Distributed System     Updates and Concurrency
                    Queries and Views      Design Documents
                            CouchApps


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
Introduction
                             Documents     Document-Oriented Data Model
                    Distributed System     Updates and Concurrency
                    Queries and Views      Design Documents
                            CouchApps


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
Introduction
                             Documents     Document-Oriented Data Model
                    Distributed System     Updates and Concurrency
                    Queries and Views      Design Documents
                            CouchApps


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
Introduction
                             Documents     Document-Oriented Data Model
                    Distributed System     Updates and Concurrency
                    Queries and Views      Design Documents
                            CouchApps


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
Introduction
                            Documents
                   Distributed System
                   Queries and Views
                           CouchApps


Replication


     shared nothing cluster




                     Kerstin Puschke      NoSQL
Introduction
                            Documents
                   Distributed System
                   Queries and Views
                           CouchApps


Replication


     shared nothing cluster
     incremental




                     Kerstin Puschke      NoSQL
Introduction
                             Documents
                    Distributed System
                    Queries and Views
                            CouchApps


Replication


     shared nothing cluster
     incremental
     latest revision only - no transfer of previous versions




                      Kerstin Puschke      NoSQL
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
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
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
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
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
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
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
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
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
Introduction
                           Documents     Views
                  Distributed System     Creating Views with Map Reduce
                  Queries and Views      Example
                          CouchApps


Queries




     fetch document by _id




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


Queries




     fetch document by _id
     no dynamic queries, no ad hoc reporting




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


Queries




     fetch document by _id
     no dynamic queries, no ad hoc reporting
     need to create views (indices) to query




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


Views

    (secondary) index
    key-value-pairs




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


Views

    (secondary) index
    key-value-pairs
    keys and values are values from documents




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


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
Introduction
                            Documents     Views
                   Distributed System     Creating Views with Map Reduce
                   Queries and Views      Example
                           CouchApps


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
Introduction
                             Documents     Views
                    Distributed System     Creating Views with Map Reduce
                    Queries and Views      Example
                            CouchApps


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
Introduction
                             Documents     Views
                    Distributed System     Creating Views with Map Reduce
                    Queries and Views      Example
                            CouchApps


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
Introduction
                             Documents     Views
                    Distributed System     Creating Views with Map Reduce
                    Queries and Views      Example
                            CouchApps


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
Introduction
                             Documents     Views
                    Distributed System     Creating Views with Map Reduce
                    Queries and Views      Example
                            CouchApps


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
Introduction
                                Documents     Views
                       Distributed System     Creating Views with Map Reduce
                       Queries and Views      Example
                               CouchApps


View
Example




   View with key date and value title, in Futon




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


Map Reduce

    map and reduce functions common in functional
    programming




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


Map Reduce

    map and reduce functions common in functional
    programming
    MapReduce: framework for concurrent, distributed
    processing of large data sets (Google)




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


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
Introduction
                           Documents     Views
                  Distributed System     Creating Views with Map Reduce
                  Queries and Views      Example
                          CouchApps


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
Introduction
                           Documents     Views
                  Distributed System     Creating Views with Map Reduce
                  Queries and Views      Example
                          CouchApps


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
Introduction
                            Documents     Views
                   Distributed System     Creating Views with Map Reduce
                   Queries and Views      Example
                           CouchApps


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
Introduction
                             Documents     Views
                    Distributed System     Creating Views with Map Reduce
                    Queries and Views      Example
                            CouchApps


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
Introduction
                            Documents     Views
                   Distributed System     Creating Views with Map Reduce
                   Queries and Views      Example
                           CouchApps


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
Introduction
                            Documents     Views
                   Distributed System     Creating Views with Map Reduce
                   Queries and Views      Example
                           CouchApps


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
Introduction
                            Documents     Views
                   Distributed System     Creating Views with Map Reduce
                   Queries and Views      Example
                           CouchApps


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
Introduction
                              Documents     Views
                     Distributed System     Creating Views with Map Reduce
                     Queries and Views      Example
                             CouchApps


Map Function
Example




   Design doc with map




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


Reduce Function
Example




   Design doc with map and reduce




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


Querying View
Example



   View without reduce




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


Querying a View
Example


   View with reduce




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


Querying a View
Example


   View with reduce




   View with reduce and group_level=2




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


Example
Blogpost with “inline” comments




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


Example
Posts and Comments in different docs




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


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
Introduction
                   Documents     Views
          Distributed System     Creating Views with Map Reduce
          Queries and Views      Example
                  CouchApps


Example
contd.




            Kerstin Puschke      NoSQL
Introduction
                            Documents
                   Distributed System
                   Queries and Views
                           CouchApps


CouchApps



    applications living in the database




                     Kerstin Puschke      NoSQL
Introduction
                             Documents
                    Distributed System
                    Queries and Views
                            CouchApps


CouchApps



    applications living in the database
    no middleware




                      Kerstin Puschke      NoSQL
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
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
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
Introduction
               Documents
      Distributed System
      Queries and Views
              CouchApps


Q&A



         Thanks for listening!




      Questions? Comments?




        Kerstin Puschke      NoSQL
Links

        The CouchDB Project
        http://couchdb.apache.org




                    Kerstin Puschke   NoSQL
Links

        The CouchDB Project
        http://couchdb.apache.org
        CouchDB Wiki
        http://wiki.apache.org/couchdb




                    Kerstin Puschke   NoSQL
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
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
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

More Related Content

Similar to CouchDB

Big Data Day LA 2016/ NoSQL track - Spark And Couchbase: Augmenting The Opera...
Big Data Day LA 2016/ NoSQL track - Spark And Couchbase: Augmenting The Opera...Big Data Day LA 2016/ NoSQL track - Spark And Couchbase: Augmenting The Opera...
Big Data Day LA 2016/ NoSQL track - Spark And Couchbase: Augmenting The Opera...Data Con LA
 
Spark and Couchbase– Augmenting the Operational Database with Spark
Spark and Couchbase– Augmenting the Operational Database with SparkSpark and Couchbase– Augmenting the Operational Database with Spark
Spark and Couchbase– Augmenting the Operational Database with SparkMatt Ingenthron
 
Building a distributed search system with Hadoop and Lucene
Building a distributed search system with Hadoop and LuceneBuilding a distributed search system with Hadoop and Lucene
Building a distributed search system with Hadoop and LuceneMirko Calvaresi
 
Azure Synapse Analytics Overview (r2)
Azure Synapse Analytics Overview (r2)Azure Synapse Analytics Overview (r2)
Azure Synapse Analytics Overview (r2)James Serra
 
Streaming Data Analytics with ksqlDB and Superset | Robert Stolz, Preset
Streaming Data Analytics with ksqlDB and Superset | Robert Stolz, PresetStreaming Data Analytics with ksqlDB and Superset | Robert Stolz, Preset
Streaming Data Analytics with ksqlDB and Superset | Robert Stolz, PresetHostedbyConfluent
 
Sql vs NoSQL-Presentation
 Sql vs NoSQL-Presentation Sql vs NoSQL-Presentation
Sql vs NoSQL-PresentationShubham Tomar
 
Introduction to the Semantic Web
Introduction to the Semantic WebIntroduction to the Semantic Web
Introduction to the Semantic WebNuxeo
 
Analyzing data with docker v4
Analyzing data with docker   v4Analyzing data with docker   v4
Analyzing data with docker v4Andreas Dewes
 
A General Purpose Extensible Scanning Query Architecture for Ad Hoc Analytics
A General Purpose Extensible Scanning Query Architecture for Ad Hoc AnalyticsA General Purpose Extensible Scanning Query Architecture for Ad Hoc Analytics
A General Purpose Extensible Scanning Query Architecture for Ad Hoc AnalyticsFlurry, Inc.
 
SplunkLive! Washington DC May 2013 - Big Data Architectural Patterns
SplunkLive! Washington DC May 2013 - Big Data Architectural PatternsSplunkLive! Washington DC May 2013 - Big Data Architectural Patterns
SplunkLive! Washington DC May 2013 - Big Data Architectural PatternsSplunk
 
Big Data - Hadoop Ecosystem
Big Data -  Hadoop Ecosystem Big Data -  Hadoop Ecosystem
Big Data - Hadoop Ecosystem nuriadelasheras
 
DustinVannoy_DataPipelines_AzureDataConf_Dec22.pdf
DustinVannoy_DataPipelines_AzureDataConf_Dec22.pdfDustinVannoy_DataPipelines_AzureDataConf_Dec22.pdf
DustinVannoy_DataPipelines_AzureDataConf_Dec22.pdfDustin Vannoy
 
Samedi SQL Québec - La plateforme data de Azure
Samedi SQL Québec - La plateforme data de AzureSamedi SQL Québec - La plateforme data de Azure
Samedi SQL Québec - La plateforme data de AzureMSDEVMTL
 
NoSql Data Management
NoSql Data ManagementNoSql Data Management
NoSql Data Managementsameerfaizan
 
Spark and Couchbase: Augmenting the Operational Database with Spark
Spark and Couchbase: Augmenting the Operational Database with SparkSpark and Couchbase: Augmenting the Operational Database with Spark
Spark and Couchbase: Augmenting the Operational Database with SparkSpark Summit
 
NoSQL and SQL Databases
NoSQL and SQL DatabasesNoSQL and SQL Databases
NoSQL and SQL DatabasesGaurav Paliwal
 
Sql azure introduction
Sql azure introductionSql azure introduction
Sql azure introductionSuherman .
 
Elasticsearch python
Elasticsearch pythonElasticsearch python
Elasticsearch pythonvaliantval2
 

Similar to CouchDB (20)

Big Data Day LA 2016/ NoSQL track - Spark And Couchbase: Augmenting The Opera...
Big Data Day LA 2016/ NoSQL track - Spark And Couchbase: Augmenting The Opera...Big Data Day LA 2016/ NoSQL track - Spark And Couchbase: Augmenting The Opera...
Big Data Day LA 2016/ NoSQL track - Spark And Couchbase: Augmenting The Opera...
 
Spark and Couchbase– Augmenting the Operational Database with Spark
Spark and Couchbase– Augmenting the Operational Database with SparkSpark and Couchbase– Augmenting the Operational Database with Spark
Spark and Couchbase– Augmenting the Operational Database with Spark
 
Building a distributed search system with Hadoop and Lucene
Building a distributed search system with Hadoop and LuceneBuilding a distributed search system with Hadoop and Lucene
Building a distributed search system with Hadoop and Lucene
 
Azure Synapse Analytics Overview (r2)
Azure Synapse Analytics Overview (r2)Azure Synapse Analytics Overview (r2)
Azure Synapse Analytics Overview (r2)
 
Streaming Data Analytics with ksqlDB and Superset | Robert Stolz, Preset
Streaming Data Analytics with ksqlDB and Superset | Robert Stolz, PresetStreaming Data Analytics with ksqlDB and Superset | Robert Stolz, Preset
Streaming Data Analytics with ksqlDB and Superset | Robert Stolz, Preset
 
Sql vs NoSQL-Presentation
 Sql vs NoSQL-Presentation Sql vs NoSQL-Presentation
Sql vs NoSQL-Presentation
 
Introduction to the Semantic Web
Introduction to the Semantic WebIntroduction to the Semantic Web
Introduction to the Semantic Web
 
Analyzing data with docker v4
Analyzing data with docker   v4Analyzing data with docker   v4
Analyzing data with docker v4
 
A General Purpose Extensible Scanning Query Architecture for Ad Hoc Analytics
A General Purpose Extensible Scanning Query Architecture for Ad Hoc AnalyticsA General Purpose Extensible Scanning Query Architecture for Ad Hoc Analytics
A General Purpose Extensible Scanning Query Architecture for Ad Hoc Analytics
 
SplunkLive! Washington DC May 2013 - Big Data Architectural Patterns
SplunkLive! Washington DC May 2013 - Big Data Architectural PatternsSplunkLive! Washington DC May 2013 - Big Data Architectural Patterns
SplunkLive! Washington DC May 2013 - Big Data Architectural Patterns
 
Big Data - Hadoop Ecosystem
Big Data -  Hadoop Ecosystem Big Data -  Hadoop Ecosystem
Big Data - Hadoop Ecosystem
 
DustinVannoy_DataPipelines_AzureDataConf_Dec22.pdf
DustinVannoy_DataPipelines_AzureDataConf_Dec22.pdfDustinVannoy_DataPipelines_AzureDataConf_Dec22.pdf
DustinVannoy_DataPipelines_AzureDataConf_Dec22.pdf
 
Samedi SQL Québec - La plateforme data de Azure
Samedi SQL Québec - La plateforme data de AzureSamedi SQL Québec - La plateforme data de Azure
Samedi SQL Québec - La plateforme data de Azure
 
NoSQL_Night
NoSQL_NightNoSQL_Night
NoSQL_Night
 
NoSql Data Management
NoSql Data ManagementNoSql Data Management
NoSql Data Management
 
Spark and Couchbase: Augmenting the Operational Database with Spark
Spark and Couchbase: Augmenting the Operational Database with SparkSpark and Couchbase: Augmenting the Operational Database with Spark
Spark and Couchbase: Augmenting the Operational Database with Spark
 
NoSQL and SQL Databases
NoSQL and SQL DatabasesNoSQL and SQL Databases
NoSQL and SQL Databases
 
Sql azure introduction
Sql azure introductionSql azure introduction
Sql azure introduction
 
Elasticsearch python
Elasticsearch pythonElasticsearch python
Elasticsearch python
 
Nov 2011 HUG: Blur - Lucene on Hadoop
Nov 2011 HUG: Blur - Lucene on HadoopNov 2011 HUG: Blur - Lucene on Hadoop
Nov 2011 HUG: Blur - Lucene on Hadoop
 

More from Kerstin Puschke

Webentwicklung mit PHP und MySQL
Webentwicklung mit PHP und MySQLWebentwicklung mit PHP und MySQL
Webentwicklung mit PHP und MySQLKerstin Puschke
 
NoSQL-Datenbanken am Beispiel CouchDB
NoSQL-Datenbanken am Beispiel CouchDBNoSQL-Datenbanken am Beispiel CouchDB
NoSQL-Datenbanken am Beispiel CouchDBKerstin Puschke
 
Not only SQL - CouchDB und andere NoSQL-Datenbanken
Not only SQL - CouchDB und andere NoSQL-DatenbankenNot only SQL - CouchDB und andere NoSQL-Datenbanken
Not only SQL - CouchDB und andere NoSQL-DatenbankenKerstin Puschke
 
Einstieg in relationale Datenbanken mit MySQL (Folien)
Einstieg in relationale Datenbanken mit MySQL (Folien)Einstieg in relationale Datenbanken mit MySQL (Folien)
Einstieg in relationale Datenbanken mit MySQL (Folien)Kerstin Puschke
 
Einstieg in relationale Datenbanken mit MySQL (Handout)
Einstieg in relationale Datenbanken mit MySQL (Handout)Einstieg in relationale Datenbanken mit MySQL (Handout)
Einstieg in relationale Datenbanken mit MySQL (Handout)Kerstin Puschke
 
Grundlagen der Kommandozeile unter Unix/Linux (Folien)
Grundlagen der Kommandozeile unter Unix/Linux (Folien)Grundlagen der Kommandozeile unter Unix/Linux (Folien)
Grundlagen der Kommandozeile unter Unix/Linux (Folien)Kerstin Puschke
 
Grundlagen der Kommandozeile unter Unix/Linux (Handout)
Grundlagen der Kommandozeile unter Unix/Linux (Handout)Grundlagen der Kommandozeile unter Unix/Linux (Handout)
Grundlagen der Kommandozeile unter Unix/Linux (Handout)Kerstin Puschke
 

More from Kerstin Puschke (8)

oEmbed (on rails)
oEmbed (on rails)oEmbed (on rails)
oEmbed (on rails)
 
Webentwicklung mit PHP und MySQL
Webentwicklung mit PHP und MySQLWebentwicklung mit PHP und MySQL
Webentwicklung mit PHP und MySQL
 
NoSQL-Datenbanken am Beispiel CouchDB
NoSQL-Datenbanken am Beispiel CouchDBNoSQL-Datenbanken am Beispiel CouchDB
NoSQL-Datenbanken am Beispiel CouchDB
 
Not only SQL - CouchDB und andere NoSQL-Datenbanken
Not only SQL - CouchDB und andere NoSQL-DatenbankenNot only SQL - CouchDB und andere NoSQL-Datenbanken
Not only SQL - CouchDB und andere NoSQL-Datenbanken
 
Einstieg in relationale Datenbanken mit MySQL (Folien)
Einstieg in relationale Datenbanken mit MySQL (Folien)Einstieg in relationale Datenbanken mit MySQL (Folien)
Einstieg in relationale Datenbanken mit MySQL (Folien)
 
Einstieg in relationale Datenbanken mit MySQL (Handout)
Einstieg in relationale Datenbanken mit MySQL (Handout)Einstieg in relationale Datenbanken mit MySQL (Handout)
Einstieg in relationale Datenbanken mit MySQL (Handout)
 
Grundlagen der Kommandozeile unter Unix/Linux (Folien)
Grundlagen der Kommandozeile unter Unix/Linux (Folien)Grundlagen der Kommandozeile unter Unix/Linux (Folien)
Grundlagen der Kommandozeile unter Unix/Linux (Folien)
 
Grundlagen der Kommandozeile unter Unix/Linux (Handout)
Grundlagen der Kommandozeile unter Unix/Linux (Handout)Grundlagen der Kommandozeile unter Unix/Linux (Handout)
Grundlagen der Kommandozeile unter Unix/Linux (Handout)
 

Recently uploaded

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Recently uploaded (20)

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

CouchDB

  • 1. Introduction Documents Distributed System Queries and Views CouchApps CouchDB Kerstin Puschke The Next Web - Barcamp Salzburg 2011 Kerstin Puschke NoSQL
  • 2. 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
  • 3. Introduction Documents Distributed System Queries and Views CouchApps Outline 1 Introduction Kerstin Puschke NoSQL
  • 4. 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
  • 5. 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
  • 6. 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
  • 7. 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
  • 8. Introduction Documents Distributed System Queries and Views CouchApps CouchDB? Cluster Of Unreliable Commodity Hardware DataBase Kerstin Puschke NoSQL
  • 9. Introduction Documents Distributed System Queries and Views CouchApps CouchDB? Cluster Of Unreliable Commodity Hardware DataBase NoSQL database, non-relational data store Kerstin Puschke NoSQL
  • 10. 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
  • 11. 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
  • 12. 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
  • 13. 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
  • 14. 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
  • 15. Introduction Documents Distributed System Queries and Views CouchApps In the Wild BBC Kerstin Puschke NoSQL
  • 16. Introduction Documents Distributed System Queries and Views CouchApps In the Wild BBC Ubuntu One Kerstin Puschke NoSQL
  • 17. Introduction Documents Distributed System Queries and Views CouchApps In the Wild BBC Ubuntu One lots of software, websites, facebook apps, . . . Kerstin Puschke NoSQL
  • 18. Introduction Documents Distributed System Queries and Views CouchApps Getting Started RESTful HTTP/JSON API Kerstin Puschke NoSQL
  • 19. Introduction Documents Distributed System Queries and Views CouchApps Getting Started RESTful HTTP/JSON API Webserver included Kerstin Puschke NoSQL
  • 20. 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
  • 21. 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
  • 22. 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
  • 23. 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
  • 24. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps Document-Oriented Data Model abstraction layer above key-value pairs Kerstin Puschke NoSQL
  • 25. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps Document-Oriented Data Model abstraction layer above key-value pairs document: self-contained data, reasonable unit of information (invoice, business card,. . . ) Kerstin Puschke NoSQL
  • 26. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps 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
  • 27. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps 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
  • 28. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps 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
  • 29. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps 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
  • 30. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps 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
  • 31. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps 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
  • 32. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps CouchDB Document JSON Kerstin Puschke NoSQL
  • 33. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps Updates client sends full document Kerstin Puschke NoSQL
  • 34. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps Updates client sends full document append-only - new version appended to database no diffs, no partial updates Kerstin Puschke NoSQL
  • 35. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps Updates client sends full document append-only - new version appended to database no diffs, no partial updates robust and fast Kerstin Puschke NoSQL
  • 36. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps Multi Version Concurrency Control optimistic locking Kerstin Puschke NoSQL
  • 37. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps Multi Version Concurrency Control optimistic locking client sends new version of document along with old _rev Kerstin Puschke NoSQL
  • 38. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps 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
  • 39. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps 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
  • 40. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps 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
  • 41. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps 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
  • 42. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps Design Documents _id starts with _design Kerstin Puschke NoSQL
  • 43. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps Design Documents _id starts with _design create, update, replicate,. . . like any other document Kerstin Puschke NoSQL
  • 44. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps Design Documents _id starts with _design create, update, replicate,. . . like any other document no data but code Kerstin Puschke NoSQL
  • 45. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps 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
  • 46. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps 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
  • 47. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps 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
  • 48. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps 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
  • 49. Introduction Documents Document-Oriented Data Model Distributed System Updates and Concurrency Queries and Views Design Documents CouchApps 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
  • 50. Introduction Documents Distributed System Queries and Views CouchApps Replication shared nothing cluster Kerstin Puschke NoSQL
  • 51. Introduction Documents Distributed System Queries and Views CouchApps Replication shared nothing cluster incremental Kerstin Puschke NoSQL
  • 52. Introduction Documents Distributed System Queries and Views CouchApps Replication shared nothing cluster incremental latest revision only - no transfer of previous versions Kerstin Puschke NoSQL
  • 53. 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
  • 54. 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
  • 55. 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
  • 56. 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
  • 57. 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
  • 58. 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
  • 59. 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
  • 60. 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
  • 61. 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
  • 62. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps Queries fetch document by _id Kerstin Puschke NoSQL
  • 63. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps Queries fetch document by _id no dynamic queries, no ad hoc reporting Kerstin Puschke NoSQL
  • 64. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps Queries fetch document by _id no dynamic queries, no ad hoc reporting need to create views (indices) to query Kerstin Puschke NoSQL
  • 65. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps Views (secondary) index key-value-pairs Kerstin Puschke NoSQL
  • 66. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps Views (secondary) index key-value-pairs keys and values are values from documents Kerstin Puschke NoSQL
  • 67. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps 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
  • 68. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps 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
  • 69. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps 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
  • 70. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps 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
  • 71. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps 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
  • 72. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps 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
  • 73. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps View Example View with key date and value title, in Futon Kerstin Puschke NoSQL
  • 74. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps Map Reduce map and reduce functions common in functional programming Kerstin Puschke NoSQL
  • 75. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps Map Reduce map and reduce functions common in functional programming MapReduce: framework for concurrent, distributed processing of large data sets (Google) Kerstin Puschke NoSQL
  • 76. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps 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
  • 77. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps 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
  • 78. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps 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
  • 79. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps 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
  • 80. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps 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
  • 81. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps 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
  • 82. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps 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
  • 83. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps 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
  • 84. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps Map Function Example Design doc with map Kerstin Puschke NoSQL
  • 85. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps Reduce Function Example Design doc with map and reduce Kerstin Puschke NoSQL
  • 86. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps Querying View Example View without reduce Kerstin Puschke NoSQL
  • 87. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps Querying a View Example View with reduce Kerstin Puschke NoSQL
  • 88. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps Querying a View Example View with reduce View with reduce and group_level=2 Kerstin Puschke NoSQL
  • 89. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps Example Blogpost with “inline” comments Kerstin Puschke NoSQL
  • 90. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps Example Posts and Comments in different docs Kerstin Puschke NoSQL
  • 91. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps 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
  • 92. Introduction Documents Views Distributed System Creating Views with Map Reduce Queries and Views Example CouchApps Example contd. Kerstin Puschke NoSQL
  • 93. Introduction Documents Distributed System Queries and Views CouchApps CouchApps applications living in the database Kerstin Puschke NoSQL
  • 94. Introduction Documents Distributed System Queries and Views CouchApps CouchApps applications living in the database no middleware Kerstin Puschke NoSQL
  • 95. 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
  • 96. 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
  • 97. 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
  • 98. Introduction Documents Distributed System Queries and Views CouchApps Q&A Thanks for listening! Questions? Comments? Kerstin Puschke NoSQL
  • 99. Links The CouchDB Project http://couchdb.apache.org Kerstin Puschke NoSQL
  • 100. Links The CouchDB Project http://couchdb.apache.org CouchDB Wiki http://wiki.apache.org/couchdb Kerstin Puschke NoSQL
  • 101. 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
  • 102. 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
  • 103. 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