gtalug presentation on couchdb
DESCRIPTION
TRANSCRIPT
![Page 1: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/1.jpg)
Who am I?
![Page 2: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/2.jpg)
Myles Braithwaite
![Page 3: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/3.jpg)
![Page 4: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/4.jpg)
We Develop Websites
![Page 5: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/5.jpg)
What is CouchDB?
![Page 6: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/6.jpg)
Erlang
![Page 7: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/7.jpg)
Apache CouchDB is a distributed, fault-tolerant and schema-free document-oriented database accessible via a RESTful HTTP/JSON API. Among other features, it provides robust, incremental replication with bi-directional conflict detection and resolution, and is queryable and indexable using a table-oriented view engine with JavaScript acting as the default view definition language.
Quote from http://couchdb.org/.
![Page 8: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/8.jpg)
Document-Oriented Database
![Page 9: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/9.jpg)
• Each record is store as a document.
• Any number of fields of any length.
• Fields can also contain multiple pieces of data.
![Page 10: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/10.jpg)
<people> <person first_name="Myles" last_name="Braithwaite"> <emails> <email value="[email protected]"/> <email value="[email protected]"/> </emails> </person></people>
![Page 11: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/11.jpg)
[ { "first_name": "Myles", "last_name": "Braithwaite", "emails": [ { "email": "[email protected]" }, { "email": "[email protected]" } ] }]
![Page 12: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/12.jpg)
Relational Database it would require two tables
![Page 13: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/13.jpg)
What is RESTful HTTP?
![Page 14: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/14.jpg)
Does anyone not know what HTTP is?
![Page 15: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/15.jpg)
REST
• Representational State Transfer
• The foundation of all Web Services
• SOAP,
• XML-RPC,
• and basic HTTP methods like:
• POST, GET, PUT, DELETE
![Page 16: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/16.jpg)
RESTful HTTP Methods CRUD
POST Create, Update & Delete
GET Read
PUT Create & Replace
DELETE Delete
![Page 17: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/17.jpg)
“Django may be built for the Web, but CouchDB is built of the Web. I’ve never seen software that so completely embraces the philosophies behind HTTP. CouchDB makes Django look old-school in the same way that Django makes ASP look outdated.”
— Jacob Kaplan-Moss, Django Developer
![Page 18: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/18.jpg)
What is JSON?
![Page 19: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/19.jpg)
• JavaScript version of XML.
![Page 20: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/20.jpg)
• A less dramatic/lightweight version of XML.
![Page 21: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/21.jpg)
• Google and Yahoo are using it in there Web Services.
![Page 22: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/22.jpg)
Distributed
![Page 23: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/23.jpg)
![Page 24: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/24.jpg)
![Page 25: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/25.jpg)
Bi-Directional Conflict Detection and
Resolution
![Page 26: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/26.jpg)
Bi-Directional Conflict Detection and
Resolution
![Page 27: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/27.jpg)
Bi-Directional Conflict Detection and
Resolution
![Page 28: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/28.jpg)
Query Documents with JavaScript
![Page 29: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/29.jpg)
Views
![Page 30: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/30.jpg)
• Map Functions
• Reduce Functions
• Lookup Views -- Demo
• Complex Keys -- Demo
![Page 31: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/31.jpg)
function(doc) {emit(null, doc);}
Map Functions
![Page 32: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/32.jpg)
function(doc) { if (doc.first_name && doc.last_name) { var full_name = (doc.first_name + " " + doc.last_name) emit(full_name, doc); }};
Text
Map Functions
![Page 33: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/33.jpg)
Reduce Functions
function (key, values, rereduce) { return sum(values);}
![Page 34: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/34.jpg)
Futon
![Page 35: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/35.jpg)
Basically the PHPMyAdmin for
CouchDB
![Page 36: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/36.jpg)
Demo Time
![Page 37: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/37.jpg)
$ curl -X PUT -v 'http://127.0.0.1:5984/temp_database/'
> PUT /temp_database/ HTTP/1.1> User-Agent: curl> Host: 127.0.0.1:5984> Accept: */*> < HTTP/1.1 201 Created< Server: CouchDB< Date: Tue, 09 Dec 2008 20:32:15 GMT< Content-Type: text/plain;charset=utf-8< Content-Length: 11< {"ok":true}
![Page 38: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/38.jpg)
$ curl -X DELETE -v 'http://127.0.0.1:5984/temp_database/'
> DELETE /temp_database/ HTTP/1.1> User-Agent: curl> Host: 127.0.0.1:5984> Accept: */*> < HTTP/1.1 200 OK< Server: CouchDB< Date: Tue, 09 Dec 2008 20:35:26 GMT< Content-Type: text/plain;charset=utf-8< Content-Length: 11< {"ok":true}
![Page 39: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/39.jpg)
$ curl 'http://127.0.0.1:5984/'
{"couchdb":"Welcome","version":"0.8.1-incubating"}
![Page 40: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/40.jpg)
$ curl 'http://127.0.0.1:5984/address_book/'
{"db_name":"address_book","doc_count":18,"doc_del_count":2,"update_seq":117,"compact_running":false,"disk_size":242905}
![Page 41: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/41.jpg)
$ curl 'http://127.0.0.1:5984/address_book/_all_docs/'
{"total_rows":18,"offset":0,"rows":[{"id":"1074d8805eaa79dfec356d34aa719a95","key":"1074d8805eaa79dfec356d34aa719a95","value":{"rev":"3720758831"}},...
![Page 42: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/42.jpg)
$ curl 'http://127.0.0.1:5984/address_book/_all_docs?count=1'
{"total_rows":18,"offset":0,"rows":[{"id":"1074d8805eaa79dfec356d34aa719a95","key":"1074d8805eaa79dfec356d34aa719a95","value":{"rev":"3720758831"}}]}
![Page 43: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/43.jpg)
curl 'http://127.0.0.1:5984/address_book/1074d8805eaa79dfec356d34aa719a95/'
{"_id":"1074d8805eaa79dfec356d34aa719a95","_rev":"3720758831","From":{"name":"Myles Braithwaite","email":"[email protected]"},"To":"[email protected]","Subject":"Re: [TLUG]: Re: [TLUG-ANNOUNCE]: TLUG Meeting. Tue Sep 9","Date":"Wed, 10 Sep 2008 15:28:22 -0400","body":"..."}
![Page 44: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/44.jpg)
$ curl 'http://127.0.0.1:5984/address_book/1074d8805eaa79dfec356d34aa719a95?rev=3720758831'
![Page 45: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/45.jpg)
$ curl 'http://127.0.0.1:5984/address_book/1074d8805eaa79dfec356d34aa719a95?revs=true'
{"_id":"1074d8805eaa79dfec356d34aa719a95","_rev":"3720758831",..."_revs":["3720758831","1987563969","3227393092"]}
![Page 46: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/46.jpg)
$ curl 'http://127.0.0.1:5984/address_book/_view/contacts/contact_list/'
{"total_rows":5,"offset":0,"rows":[{"id":"93a31f6756545d9d59ca53fba6f92fe0","key":"Myles Braithwaite","value":{"_id":"93a31f6756545d9d59ca53fba6f92fe0","_rev":"3685624062","fn":{"family-name":"Braithwaite","given-name":"Myles"},"email":[{"value":"[email protected]","type":"Personal"},{"value":"[email protected]","type":"Work"}],"org":{"organization-name":"Monkey in your Soul"}}}...
![Page 47: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/47.jpg)
Use Cases
![Page 48: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/48.jpg)
![Page 49: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/49.jpg)
![Page 50: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/50.jpg)
![Page 51: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/51.jpg)
![Page 52: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/52.jpg)
What CouchDB should not be used for!
• A relational database.
• A replacement for relational databases.
• An object-oriented database. Or more specifically, meant to function as a seamless persistence layer for an OO programming language.
![Page 53: GTALUG Presentation on CouchDB](https://reader034.vdocument.in/reader034/viewer/2022052504/553b7c644a79595c038b46c4/html5/thumbnails/53.jpg)
Pictures• http://flickr.com/photos/
83737641@N00/2377691249/
• http://flickr.com/photos/dragon2309/1490657223/
• http://flickr.com/photos/herzogbr/359841353/
• http://flickr.com/photos/irisheyes/1160297224/
• http://flickr.com/photos/jessefriedman/1435220149/
• http://flickr.com/photos/tomnatt/2763592134/
• http://flickr.com/photos/theo_reth/188334429/
• http://flickr.com/photos/photonquantique/2596581870/
• http://flickr.com/photos/malcolmtredinnick/202679799/
• http://flickr.com/photos/andrewmoir/3012531/
• http://flickr.com/photos/apesara/2499666202/
• http://flickr.com/photos/mehrwert/18711050/
• http://flickr.com/photos/bohemianrabbit/2815366720/
• http://flickr.com/photos/ianturton/2155423758/
• http://flickr.com/photos/mbiddulph/2037845171/
• http://flickr.com/photos/cgc/130309167/
• http://www.flickr.com/photos/daveaustria/2654190796