• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
An introduction to CouchDB
 

An introduction to CouchDB

on

  • 12,294 views

This is a talk I presented at University Limerick to give people an introduction into CouchDB.

This is a talk I presented at University Limerick to give people an introduction into CouchDB.

What is it? How does it generally work? Introducing new concepts, etc.

Statistics

Views

Total Views
12,294
Views on SlideShare
8,434
Embed Views
3,860

Actions

Likes
26
Downloads
406
Comments
1

18 Embeds 3,860

http://nosql.mypopescu.com 3611
http://www.mostofreddy.com.ar 85
http://www.slideshare.net 72
http://varga-multimedia.com 51
http://translate.googleusercontent.com 7
http://youthvoices.dev 5
http://sphere.lithify.me 4
http://localhost 4
https://abs.twimg.com 3
http://bender 3
http://webcache.googleusercontent.com 3
http://flexbuddha.wordpress.com 3
http://127.0.0.1 2
http://francisvarga.posterous.com 2
http://www.thehouseofblogs.com 2
http://bender.radada.gruik.org 1
app://nl.ditnet.couchdb 1
https://twitter.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />

An introduction to CouchDB An introduction to CouchDB Presentation Transcript

  • 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!
  • 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___ ;-))