SlideShare a Scribd company logo
An introduction to #CouchDB
        Sit back and relax




    @davidcoallier, University Limerick 2010
WTF IS COUCH?
- Highly concurrent database server
- Schema free, document based database
- RESTFul API
- Map/Reduce Views generation
- EASY replication (like... really)
... AGAIN.. WTF?!
HISTORY CLASS TIME!
An introduction to CouchDB
32 CouchDB servers
                                            2 datacenters
                                   SSL based user auth, sharding, etc.




This is the only BBC transparent logo I found and it’s not BBC World News using CouchDB but BBC.
           See: http://www.erlang-factory.com/conference/London2009/speakers/endafarrell
Ubuntu One
mozilla.org
       IBM
      Apple
  myspace.com
      ebay
     meebo
oh so many more.
DOCUMENT BASED
KEY/VALUE STORE...
key       value
  name       david
  email    e@e.com
 phones      Array
createdAt timetsamp
DOCUMENT BASED WHAT?
- Dictionary of data
- JSON Objects
- A doc can have attachments
- Auto generated IDs (CLAP NOW)
- Revisions (THAT’S RIGHT..)
DOCUMENT

{
    "_id": "3fc3b3bf3c101e15fa7d08e2ecf9c900",
    "_rev": "1-34c5c7adcf1fdb8898498d1e6b64ebdd",
    "firstname": "David",
    "email": "david@echolibre.com"
}
DOCUMENT
{
    "_id": "3fc3b3bf3c101e15fa7d08e2ecf9c900",
    "_rev": "1-34c5c7adcf1fdb8898498d1e6b64ebdd",
    "firstname": "David",
    "email": "david@echolibre.com",
    "phones": {
        "mobile": "086x209x69",
        "home": "none"
    },
    "createdAt": "2009-09-16T22:12:43Z"
}
key       value
  name       david
  email    e@e.com
 phones      Array
createdAt timetsamp
WHAT ABOUT MY CRUD?

   - Create     PUT /db/docid
   - Retrieve   GET /db/docid
   - Update     POST /db/docid
   - Delete     DELETE /db/docid
VIEWS

- Persistent representation of docs
- Prod is solid. No _temp shit.
- Javascript, Erlang, Python, wtf ever.
MAP/REDUCE ...
JAVASCRIPT
MAP

map: function(doc) {
    if (doc.firstname) {
        emit(doc.firstname, doc);
    }
}
MAP
%% Map Function
fun({Doc}) ->
     case {proplists:get_value(<<"firstname">>, Doc)} of
    {undefined} ->
          false;
    {Name} ->
          Emit(Name, Doc);
     _ ->
          ok
     end
end.
fun({Doc}) ->
    Emitter = fun(Doc) ->
        Name = proplists:get_value(<<"name">>, Doc, null),

              Emit(Name, Doc)
       end,

       HasRequiredFields = fun(Doc) ->
            case {proplists:is_defined(<<"firstname">>, Doc)} of
                {true} ->
                    Emitter(Doc);
                _->
                    false
            end
       end,

       HasRequiredFields(Doc)
end.
MAP/REDUCE EXAMPLE
MAP
{
    "_id": "3fc3b3bf3c101e15fa7d08e2ecf9c900",
    "_rev": "1-34c5c7adcf1fdb8898498d1e6b64ebdd",
    "firstname": "David",
    "email": "david@echolibre.com",
    "phones": {
        "mobile": "086x209x69",
        "home": "none"
    },
    "createdAt": "2009-09-16T22:12:43Z",
    "tags": ["cool", "php", "couchdb", "skynet"]
}
MAP

map: function(doc) {
    if (doc.tags && docs.tags.length > 0) {
        for (var i = 0; i < doc.tags.length; i++) {
            emit(doc.tags[i], 1);
        }
    }
}
REDUCE
map: function(doc) {
    if (doc.tags && docs.tags.length > 0) {
        for (var i = 0; i < doc.tags.length; i++) {
            emit(doc.tags[i], 1);
        }
    }
},

reduce: function(tag, counts) {
    int sum = 0;
    for(var i = 0; i < counts.length; i++) {
        sum += counts[i];
    }
    return sum;
}
REDUCE

function(tag, counts) {
    int sum = 0;
    for(var i = 0; i < counts.length; i++) {
        sum += counts[i];
    }
    return sum;
}
REDUCE
{
    "total_rows":4,
    "rows":[
        { "key":"cool",
          "value":1},

        { "key":"php",
          "value":1},

        { "key":"couchdb",
          "value":1},

        { "key":"skynet",
          "value":1},
    ]
}
REDUCE TRICKS
map: function(doc) {
    if (doc.tags && docs.tags.length > 0) {
        for (var i = 0; i < doc.tags.length; i++) {
            emit(doc.tags[i], 1);
        }
    }
}


reduce: "_count"
REDUCE
{
    "total_rows":4,
    "rows":[
        { "key":"cool",
          "value":1},

        { "key":"php",
          "value":1},

        { "key":"couchdb",
          "value":1},

        { "key":"skynet",
          "value":1},
    ]
}
REDUCE
map: function(doc) {
    if (doc.tags && docs.tags.length > 0) {
        for (var i = 0; i < doc.tags.length; i++) {
            emit(doc.tags[i], "yer ma");
        }
    }
},

reduce: function (tag, count) {
    return sum(tag);
}
THEN...
BEWARE OF REDUCE VALUES
REPLICATION


  It fuckin’ rules.
REPLICATION

      Easy (See later futon ;-))
        Continuous... or not :P
        Replicates your views
Replicate only what you need (filter?)
REPLICATION
                   curl -X POST http://localhost:5984/_replicate 
'{"source":"/dbname", "target": "http://localhost:5555/otherdb", "continuous": true}'
REPLICATION
Source              The boss               Target

         changes?              watcha
                               need??
      target
    needs x, y, z              save them
REPLICATION
MASTER / SLAVES
REPLICATION
MASTER / SLAVES
REPLICATION
MULTI MASTER
REPLICATION
MULTI MASTER
REPLICATION
  USE CASE



    Automated job
to validate and test data
 and do bunch of shits
FUTON
FUTON
NOTE TO SELF.


   Show them.




                Open up CouchDBX
COOL THINGS
         Authorization
        CouchDB Lucene
            Lounge
          CouchDBX
           Couchio
           Cloudant

A bunch of random bits and pieces
COMPLETE SHITE COMING UP


                                                      eas
                                               r e id
                                            sha
                                        W
                                  le! NO
                                 p
                           s peo
                       cus
                   Dis
CONCEPTS AND IDEAS


      Graph Theory




                                                        ...
                                                  ss ion
                                               u
                                         a disc
                                     t
                              d star
                     tr   y an
CONCEPTS AND IDEAS


     Ghost Replication




                                                            ...
                                                      ss ion
                                                   u
                                             a disc
                                         t
                                  d star
                         tr   y an
CONCEPTS AND IDEAS


   Shared Index Replication




                                                                 ...
                                                           ss ion
                                                        u
                                                  a disc
                                              t
                                       d star
                              tr   y an
QUESTIONS?
ME! MEEE!!!


   @davidcoallier
david@echolibre.com
THANKS
LINKS

- https://nosqleast.com/2009/slides/miller-couchdb.pdf
- http://couch.io
- http://cloudant.com
- http://wiki.apache.org/couchdb/CouchDB_in_the_wild
- irc://couchdb@freenode.net (Bug jan___ ;-))

More Related Content

What's hot (18)

PDF
Dealing with Azure Cosmos DB
Mihail Mateev
 
PDF
Symfony Day 2010 Doctrine MongoDB ODM
Jonathan Wage
 
PDF
Python-CouchDB Training at PyCon PL 2012
Stefan Kögl
 
PPTX
Mongo db queries
ssuser6d5faa
 
PDF
Doctrine for NoSQL
Benjamin Eberlei
 
PDF
Doctrine and NoSQL
Benjamin Eberlei
 
PPTX
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
MongoDB
 
PPTX
Drupal8 migrate
John Doyle
 
PDF
Webinar: Building Your First App with MongoDB and Java
MongoDB
 
PPTX
Render Caching for Drupal 8
John Doyle
 
PDF
Kicking ass with redis
Dvir Volk
 
PDF
10 Key MongoDB Performance Indicators
iammutex
 
PDF
MongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your Data
MongoDB
 
PPTX
MongoDB-SESSION03
Jainul Musani
 
PDF
Nko workshop - node js & nosql
Simon Su
 
PDF
MongoDB Performance Tuning
MongoDB
 
PDF
mongodb-introduction
Tse-Ching Ho
 
PDF
All Things Open 2016 -- Database Programming for Newbies
Dave Stokes
 
Dealing with Azure Cosmos DB
Mihail Mateev
 
Symfony Day 2010 Doctrine MongoDB ODM
Jonathan Wage
 
Python-CouchDB Training at PyCon PL 2012
Stefan Kögl
 
Mongo db queries
ssuser6d5faa
 
Doctrine for NoSQL
Benjamin Eberlei
 
Doctrine and NoSQL
Benjamin Eberlei
 
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
MongoDB
 
Drupal8 migrate
John Doyle
 
Webinar: Building Your First App with MongoDB and Java
MongoDB
 
Render Caching for Drupal 8
John Doyle
 
Kicking ass with redis
Dvir Volk
 
10 Key MongoDB Performance Indicators
iammutex
 
MongoDB .local Toronto 2019: Using Change Streams to Keep Up with Your Data
MongoDB
 
MongoDB-SESSION03
Jainul Musani
 
Nko workshop - node js & nosql
Simon Su
 
MongoDB Performance Tuning
MongoDB
 
mongodb-introduction
Tse-Ching Ho
 
All Things Open 2016 -- Database Programming for Newbies
Dave Stokes
 

Viewers also liked (20)

PDF
CouchDB Vs MongoDB
Gabriele Lana
 
PDF
Apache CouchDB
Trinh Phuc Tho
 
PPT
Couch db
Rashmi Agale
 
PDF
CouchApps: Requiem for Accidental Complexity
Federico Galassi
 
PPT
CouchDB
Niklas Gustavsson
 
PDF
CouchDB
codebits
 
PDF
Conhecendo o CouchDB
Henrique Gogó
 
PDF
Curso AngularJS - Parte 2
Alvaro Viebrantz
 
KEY
ZendCon 2011 Learning CouchDB
Bradley Holt
 
PDF
CouchDB at its Core: Global Data Storage and Rich Incremental Indexing at Clo...
StampedeCon
 
PDF
Migrating to CouchDB
John Wood
 
ZIP
CouchDB-Lucene
Martin Rehfeld
 
PPTX
CouchDB Day NYC 2017: Introduction to CouchDB 2.0
IBM Cloud Data Services
 
PDF
Couch Db In 60 Minutes
George Ang
 
PDF
CouchDB at New York PHP
Bradley Holt
 
PDF
Couch db@nosql+taiwan
Kenzou Yeh
 
PDF
CouchDB – A Database for the Web
Karel Minarik
 
PDF
Couch db
arunamore
 
KEY
Real World CouchDB
John Wood
 
PDF
広島アニメ関連イベントカレンダー(仮)はじめました
Yoshitake Takata
 
CouchDB Vs MongoDB
Gabriele Lana
 
Apache CouchDB
Trinh Phuc Tho
 
Couch db
Rashmi Agale
 
CouchApps: Requiem for Accidental Complexity
Federico Galassi
 
CouchDB
codebits
 
Conhecendo o CouchDB
Henrique Gogó
 
Curso AngularJS - Parte 2
Alvaro Viebrantz
 
ZendCon 2011 Learning CouchDB
Bradley Holt
 
CouchDB at its Core: Global Data Storage and Rich Incremental Indexing at Clo...
StampedeCon
 
Migrating to CouchDB
John Wood
 
CouchDB-Lucene
Martin Rehfeld
 
CouchDB Day NYC 2017: Introduction to CouchDB 2.0
IBM Cloud Data Services
 
Couch Db In 60 Minutes
George Ang
 
CouchDB at New York PHP
Bradley Holt
 
Couch db@nosql+taiwan
Kenzou Yeh
 
CouchDB – A Database for the Web
Karel Minarik
 
Couch db
arunamore
 
Real World CouchDB
John Wood
 
広島アニメ関連イベントカレンダー(仮)はじめました
Yoshitake Takata
 
Ad

Similar to An introduction to CouchDB (20)

PPTX
ES6 is Nigh
Domenic Denicola
 
PDF
Nosql hands on handout 04
Krishna Sankar
 
PDF
CouchDB Mobile - From Couch to 5K in 1 Hour
Peter Friese
 
PDF
Elixir - GDG - Nantes
Axel CATELAND
 
PDF
NoSQL & MongoDB
Shuai Liu
 
PDF
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
Johannes Hoppe
 
PDF
PostgreSQL Open SV 2018
artgillespie
 
PDF
03 introduction to graph databases
Neo4j
 
PPTX
Spark - Philly JUG
Brian O'Neill
 
PDF
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
Felipe Prado
 
PDF
Solving the Riddle of Search: Using Sphinx with Rails
freelancing_god
 
PDF
Introduction to spark
Duyhai Doan
 
PDF
Introduction to source{d} Engine and source{d} Lookout
source{d}
 
PPTX
Gpu programming with java
Gary Sieling
 
PDF
GOTO 2011 preso: 3x Hadoop
fvanvollenhoven
 
PPTX
Big Data Analytics 3: Machine Learning to Engage the Customer, with Apache Sp...
MongoDB
 
PDF
A bit about Scala
Vladimir Parfinenko
 
PDF
Hadoop + Cassandra: Fast queries on data lakes, and wikipedia search tutorial.
Natalino Busa
 
PDF
Rust tutorial from Boston Meetup 2015-07-22
nikomatsakis
 
PDF
Koalas: Making an Easy Transition from Pandas to Apache Spark
Databricks
 
ES6 is Nigh
Domenic Denicola
 
Nosql hands on handout 04
Krishna Sankar
 
CouchDB Mobile - From Couch to 5K in 1 Hour
Peter Friese
 
Elixir - GDG - Nantes
Axel CATELAND
 
NoSQL & MongoDB
Shuai Liu
 
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
Johannes Hoppe
 
PostgreSQL Open SV 2018
artgillespie
 
03 introduction to graph databases
Neo4j
 
Spark - Philly JUG
Brian O'Neill
 
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
Felipe Prado
 
Solving the Riddle of Search: Using Sphinx with Rails
freelancing_god
 
Introduction to spark
Duyhai Doan
 
Introduction to source{d} Engine and source{d} Lookout
source{d}
 
Gpu programming with java
Gary Sieling
 
GOTO 2011 preso: 3x Hadoop
fvanvollenhoven
 
Big Data Analytics 3: Machine Learning to Engage the Customer, with Apache Sp...
MongoDB
 
A bit about Scala
Vladimir Parfinenko
 
Hadoop + Cassandra: Fast queries on data lakes, and wikipedia search tutorial.
Natalino Busa
 
Rust tutorial from Boston Meetup 2015-07-22
nikomatsakis
 
Koalas: Making an Easy Transition from Pandas to Apache Spark
Databricks
 
Ad

More from David Coallier (17)

PDF
Data Science at Scale @ barricade.io
David Coallier
 
PDF
Data Science, what even?!
David Coallier
 
PDF
Data Science, what even...
David Coallier
 
PDF
PRISM seed-stage Investor Deck
David Coallier
 
PDF
The Artful Business of Data Mining: Computational Statistics with Open Source...
David Coallier
 
KEY
Taking PHP to the next level
David Coallier
 
KEY
Mobile Cloud Architectures
David Coallier
 
KEY
Taking PHP To the next level
David Coallier
 
KEY
Orchestra at EngineYard
David Coallier
 
KEY
The Orchestra Platform
David Coallier
 
KEY
Breaking Technologies
David Coallier
 
KEY
Building APIs with FRAPI
David Coallier
 
KEY
RESTful APIs and FRAPI
David Coallier
 
PDF
Open Source for the greater good
David Coallier
 
PDF
PHP 5.3, a walkthrough
David Coallier
 
PDF
RESTful APIs and FRAPI, a matter of minutes
David Coallier
 
KEY
Get ready for web3.0! Open up your app!
David Coallier
 
Data Science at Scale @ barricade.io
David Coallier
 
Data Science, what even?!
David Coallier
 
Data Science, what even...
David Coallier
 
PRISM seed-stage Investor Deck
David Coallier
 
The Artful Business of Data Mining: Computational Statistics with Open Source...
David Coallier
 
Taking PHP to the next level
David Coallier
 
Mobile Cloud Architectures
David Coallier
 
Taking PHP To the next level
David Coallier
 
Orchestra at EngineYard
David Coallier
 
The Orchestra Platform
David Coallier
 
Breaking Technologies
David Coallier
 
Building APIs with FRAPI
David Coallier
 
RESTful APIs and FRAPI
David Coallier
 
Open Source for the greater good
David Coallier
 
PHP 5.3, a walkthrough
David Coallier
 
RESTful APIs and FRAPI, a matter of minutes
David Coallier
 
Get ready for web3.0! Open up your app!
David Coallier
 

Recently uploaded (20)

PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 

An introduction to CouchDB