SlideShare a Scribd company logo
Introduction to CouchDB
By Bogdan Sabau, SoftVision
INTRODUCTION
Databases
Databases
Relational
Databases
Object oriented
Databases
Graph
Databases
Key-Value based
Databases
Document based
WHAT IS COUCHDB?
• A scalable, fault-tolerant, and schema-free
document-oriented database
• A RESTful HTTP/JSON API accessible from
many programming libraries and tools
• Incremental Map/Reduce queries written in
any language (JavaScript support built-in)
• Incremental and flexible replication with
conflict management
SCHEMA FREE DOCUMENT
What does it means?
• It means that you don’t need to think to much
upfront about what your data will be
structured like. You don’t need to think about
relations or what might be needed for the
future. You just put the data as it currently is
into the database and in case it changes, you
just change the documents.
Relational model
id firstName lastName
1 Danila Prepeleac
2 Gheorghe Doja
customerId phoneTypeId phoneNumber
1 1 004075123321
1 2 064500100
2 1 +4072600300
Customers
Phones
id Type
1 Mobile
2 Home
PhoneTypes
Document based
{
"_id":"1",
"_rev":"1c7762a779effe1398d8d2ea36ff958a6",
"firstName":"Gheorghe",
"lastName":"Doja",
"phones":
{
"mobile":"004075123321",
"home":"064500100„
}
}
Document based
{
"_id":"1",
"_rev":"1c7762a779effe1398d8d2ea36ff958a6",
"firstName":"Gheorghe",
"lastName":"Doja",
"phones":
{
"mobile":"004075123321",
"home":"064500100„
}
}
Key, unique, it can me
autogenerated (UUID) or the
user can give it
Document based
{
"_id":"1",
"_rev":"1c7762a779effe1398d8d2ea36ff958a6",
"firstName":"Gheorghe",
"lastName":"Doja",
"phones":
{
"mobile":"004075123321",
"home":"064500100„
}
}
Key, unique, it can me
autogenerated (UUID) or the
user can give it
Revision number. Yes! It has
revisions!
CRUD OPERATIONS
CRUD Operations
• CouchDB speaks the language of the web:
REST, HTTP, and JSON are how CouchDB works
natively
• Calls are made to the database via HTTP (we
can use anything that talks HTTP)
• Responses come back as JSON
Create database:
bash$ curl -X PUT http://localhost:5984/contacts
{"ok":true}
bash$ curl -X PUT http://localhost:5984/contacts/1 -d
'{"firstName":"Gheorghe","lastName":"Doja","phones":{"mobile":"004075123321","home":"4500100"}}'
{"ok":true,"id":"1","rev":"1-c7762a779effe1398d8d2ea36ff958a6"}
bash$ curl -X GET http://localhost:5984/contacts/_all_docs
{"total_rows":1,"offset":0,"rows":[
{"id":"1","key":"1","value":{"rev":"1-c7762a779effe1398d8d2ea36ff958a6"}}
]}
Get all documents from a database
bash$ curl -X GET http://localhost:5984/contacts/1
{"_id":"1","_rev":"1-
c7762a779effe1398d8d2ea36ff958a6","firstName":"Gheorghe","lastName":"Doja","phones":{"mobile":"004075123321","home":"064500100
"}}
Get a specific document
bash$ curl -X PUT http://localhost:5984/contacts/1 -d '{"_id":"1","_rev":"1-c7762a779effe1398d8d2ea36ff958a6","firstName":"Gheorgh
e","lastName":"Doja","phones":{"mobile":"004075123000","home":"+4064500100"}}‘
{"ok":true,"id":"1","rev":"2-875f4f380fe5e3eeb5fbaeb495fc3599"}
Updates a document
bash$ curl -X DELETE http://localhost:5984/contacts/1?rev="2-875f4f380fe5e3eeb5fbaeb495fc3599"
{"ok":true,"id":"1","rev":"3-de88253ac3cb9463aac609d5fdfd3135"}
Delete a document
Create a new document:
Updating documents
• Highly concurent
• It can serve a high number of parallel
requests.
• MVCC (Multiversion concurrency control)
Updating a document
_rev: 1
CouchDB
Updating a document
_rev: 1
CouchDB
_rev: 1_rev: 1
DerpDerpina
Updating a document
_rev: 1
CouchDB
_rev: 1_rev: 1
DerpDerpina
Updating a document
_rev: 1
CouchDB
_rev: 1_rev: 1
DerpDerpina
Updating a document
_rev: 2
CouchDB
_rev: 1
Derpina
Updating a document
_rev: 2
CouchDB
_rev: 1
Derpina
Updating a document
_rev: 2
CouchDB
_rev: 1
Derpina
Updating a document
_rev: 2
CouchDB
_rev: 1
Derpina
Updating a document
_rev: 2
CouchDB
_rev: 1
Derpina
_rev: 2
Derpina
Updating a document
_rev: 2
CouchDB
_rev: 2
Derpina
Updating a document
_rev: 2
CouchDB
_rev: 2
Derpina
Updating a document
_rev: 3
CouchDB
Introduction to CouchDB
MAP/REDUCE FUNCTIONS
Introduction to CouchDB
Views
• Are stored as an accessible web resource on
disk and incrementally updated as well as
replicated with the database
• Each view defines a map function, and can
define a reduce function
One simple view
function(doc) {
if (doc.ocupation == "domnitor") {
emit(doc.ocupation, doc.firstName + ' ' + doc.lastName);
}
}
input
output
key value
{
_id: "534ce91c445da85f636284856c000c77",
_rev: "1-36d8948a4dc06aad20dfc9a95ad12de1",
firstName: "Bogdan",
lastName: "Sabau",
ocupation: "sportiv"
}
{
_id: "534ce91c445da85f636284856c001087",
_rev: "2-eb737c5882c8e7e351a4f19678eeb9f7",
firstName: "Gheorghe",
lastName: "Doja",
ocupation: "nobil"
}
{
_id: "534ce91c445da85f636284856c001c49",
_rev: "1-35972e6ee7c7ab828d4110c3dbc3a4de",
firstName: "Iacob",
lastName: "Heraclide",
ocupation: "domnitor"
}
{
_id: "534ce91c445da85f636284856c001eb2",
_rev: "1-91c5e4f0cc0836b5f4d0e4bcf3d66467",
firstName: "Alexandru",
lastName: "Lapusneanu",
ocupation: "domnitor"
}
{
_id: "534ce91c445da85f636284856c002529",
_rev: "1-a58e090b6138abf648eb65cbcd077ed7",
firstName: "Constantin",
lastName: "Karadja",
ocupation: "diplomat"
}
Output in Futon
Reduce function
Reduce function
REPLICATION
Replication
• Peer to peer
• Online/Offline
• Conflict detection and resolution
• Any number of nodes
Unidirectional
Bidirectional
Continuous
8
Filtered
Filter
function
QUESTIONS?

More Related Content

What's hot (20)

PPTX
Building Next-Generation Web APIs with JSON-LD and Hydra
Markus Lanthaler
 
PPTX
User Data Management with MongoDB
MongoDB
 
PDF
Session 5 - NGSI-LD Advanced Operations | Train the Trainers Program
FIWARE
 
PDF
Semi Formal Model for Document Oriented Databases
Daniel Coupal
 
PPTX
IOOF IT System Modernisation
MongoDB
 
PPTX
JSON-LD update DC 2017
Gregg Kellogg
 
PPTX
Tutorial: Building Your First App with MongoDB Stitch
MongoDB
 
PDF
MongoDB Europe 2016 - Who’s Helping Themselves To Your Data? Demystifying Mon...
MongoDB
 
PPTX
Webinar: Best Practices for Getting Started with MongoDB
MongoDB
 
PDF
MongoDB and RDBMS
francescapasha
 
PPTX
Jumpstart: Introduction to Schema Design
MongoDB
 
PDF
MongoDB .local Munich 2019: Still Haven't Found What You Are Looking For? Use...
MongoDB
 
PDF
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
FIWARE
 
PPTX
Data Analytics: Understanding Your MongoDB Data
MongoDB
 
PPTX
Elastic search intro-@lamper
medcl
 
KEY
JSON-LD: JSON for Linked Data
Gregg Kellogg
 
PDF
CouchDB at New York PHP
Bradley Holt
 
PPTX
MongoDB Days Silicon Valley: Introducing MongoDB 3.2
MongoDB
 
PPTX
Creating a Single View: Data Design and Loading Strategies
MongoDB
 
PDF
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB
 
Building Next-Generation Web APIs with JSON-LD and Hydra
Markus Lanthaler
 
User Data Management with MongoDB
MongoDB
 
Session 5 - NGSI-LD Advanced Operations | Train the Trainers Program
FIWARE
 
Semi Formal Model for Document Oriented Databases
Daniel Coupal
 
IOOF IT System Modernisation
MongoDB
 
JSON-LD update DC 2017
Gregg Kellogg
 
Tutorial: Building Your First App with MongoDB Stitch
MongoDB
 
MongoDB Europe 2016 - Who’s Helping Themselves To Your Data? Demystifying Mon...
MongoDB
 
Webinar: Best Practices for Getting Started with MongoDB
MongoDB
 
MongoDB and RDBMS
francescapasha
 
Jumpstart: Introduction to Schema Design
MongoDB
 
MongoDB .local Munich 2019: Still Haven't Found What You Are Looking For? Use...
MongoDB
 
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
FIWARE
 
Data Analytics: Understanding Your MongoDB Data
MongoDB
 
Elastic search intro-@lamper
medcl
 
JSON-LD: JSON for Linked Data
Gregg Kellogg
 
CouchDB at New York PHP
Bradley Holt
 
MongoDB Days Silicon Valley: Introducing MongoDB 3.2
MongoDB
 
Creating a Single View: Data Design and Loading Strategies
MongoDB
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB
 

Similar to Introduction to CouchDB (20)

PDF
Apache CouchDB talk at Ontario GNU Linux Fest
Myles Braithwaite
 
KEY
Couchdb: No SQL? No driver? No problem
delagoya
 
KEY
CouchDB : More Couch
delagoya
 
PDF
Python-CouchDB Training at PyCon PL 2012
Stefan Kögl
 
PPTX
Couch db 浅漫游.
shyboyzk
 
ODP
Intro to CouchDB
sbisbee
 
PDF
Introduction to CouchDB - LA Hacker News
Michael Parker
 
PDF
CouchDB: A NoSQL database
Rubyc Slides
 
KEY
OSCON 2011 Learning CouchDB
Bradley Holt
 
PDF
Meet Couch DB
estialvarez
 
PDF
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Myles Braithwaite
 
PPTX
Intro to CouchDB
benaldred
 
PPTX
Cluster of unreliable commodity hardware (couchdb) (2)
Namitha Acharya
 
PPTX
Couch DB
Namitha Acharya
 
PDF
Igor Davydenko
SCRUMguides
 
ODP
Introducing CouchDB
Hatem Ben Yacoub
 
PDF
Eve - REST API for Humans™
Nicola Iarocci
 
PDF
CouchDB Mobile - From Couch to 5K in 1 Hour
Peter Friese
 
PDF
Introduction to using MongoDB with Ruby
Jonathan Holloway
 
Apache CouchDB talk at Ontario GNU Linux Fest
Myles Braithwaite
 
Couchdb: No SQL? No driver? No problem
delagoya
 
CouchDB : More Couch
delagoya
 
Python-CouchDB Training at PyCon PL 2012
Stefan Kögl
 
Couch db 浅漫游.
shyboyzk
 
Intro to CouchDB
sbisbee
 
Introduction to CouchDB - LA Hacker News
Michael Parker
 
CouchDB: A NoSQL database
Rubyc Slides
 
OSCON 2011 Learning CouchDB
Bradley Holt
 
Meet Couch DB
estialvarez
 
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Myles Braithwaite
 
Intro to CouchDB
benaldred
 
Cluster of unreliable commodity hardware (couchdb) (2)
Namitha Acharya
 
Couch DB
Namitha Acharya
 
Igor Davydenko
SCRUMguides
 
Introducing CouchDB
Hatem Ben Yacoub
 
Eve - REST API for Humans™
Nicola Iarocci
 
CouchDB Mobile - From Couch to 5K in 1 Hour
Peter Friese
 
Introduction to using MongoDB with Ruby
Jonathan Holloway
 
Ad

Recently uploaded (20)

PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Ad

Introduction to CouchDB