GTALUG Presentation on CouchDB

1,035 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,035
On SlideShare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
19
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

GTALUG Presentation on CouchDB

  1. 1. Who am I?
  2. 2. Myles Braithwaite
  3. 3. We Develop Websites
  4. 4. What is CouchDB?
  5. 5. Erlang
  6. 6. 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/.
  7. 7. Document-Oriented Database
  8. 8. • Each record is store as a document. • Any number of fields of any length. • Fields can also contain multiple pieces of data.
  9. 9. <people> <person first_name=quot;Mylesquot; last_name=quot;Braithwaitequot;> <emails> <email value=quot;me@myles.tkquot;/> <email value=quot;myles@miys.netquot;/> </emails> </person> </people>
  10. 10. [ { quot;first_namequot;: quot;Mylesquot;, quot;last_namequot;: quot;Braithwaitequot;, quot;emailsquot;: [ { quot;emailquot;: quot;me@myles.tkquot; }, { quot;emailquot;: quot;myles@miys.netquot; } ] } ]
  11. 11. Relational Database it would require two tables
  12. 12. What is RESTful HTTP?
  13. 13. Does anyone not know what HTTP is?
  14. 14. REST • Representational State Transfer • The foundation of all Web Services • SOAP, • XML-RPC, • and basic HTTP methods like: • POST, GET, PUT, DELETE
  15. 15. RESTful HTTP Methods CRUD POST Create, Update & Delete GET Read PUT Create & Replace DELETE Delete
  16. 16. “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
  17. 17. What is JSON?
  18. 18. • JavaScript version of XML.
  19. 19. • A less dramatic/lightweight version of XML.
  20. 20. • Google and Yahoo are using it in there Web Services.
  21. 21. Distributed
  22. 22. Bi-Directional Conflict Detection and Resolution
  23. 23. Bi-Directional Conflict Detection and Resolution
  24. 24. Bi-Directional Conflict Detection and Resolution
  25. 25. Query Documents with JavaScript
  26. 26. Views
  27. 27. • Map Functions • Reduce Functions • Lookup Views -- Demo • Complex Keys -- Demo
  28. 28. Map Functions function(doc) { emit(null, doc); }
  29. 29. Map Functions function(doc) { if (doc.first_name && doc.last_name) { var full_name =Text (doc.first_name + quot; quot; + doc.last_name) emit(full_name, doc); } };
  30. 30. Reduce Functions function (key, values, rereduce) { return sum(values); }
  31. 31. Futon
  32. 32. Basically the PHPMyAdmin for CouchDB
  33. 33. Demo Time
  34. 34. $ 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 < {quot;okquot;:true}
  35. 35. $ 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 < {quot;okquot;:true}
  36. 36. $ curl 'http://127.0.0.1:5984/' {quot;couchdbquot;:quot;Welcomequot;,quot;versionquot;:quot;0.8 .1-incubatingquot;}
  37. 37. $ curl 'http://127.0.0.1:5984/ address_book/' {quot;db_namequot;:quot;address_bookquot;,quot;doc_countquot;: 18,quot;doc_del_countquot;:2,quot;update_seqquot;: 117,quot;compact_runningquot;:false,quot;disk_sizequot;: 242905}
  38. 38. $ curl 'http://127.0.0.1:5984/ address_book/_all_docs/' {quot;total_rowsquot;:18,quot;offsetquot;:0,quot;rowsquot;:[ {quot;idquot;:quot;1074d8805eaa79dfec356d34aa719a95quot;, quot;keyquot;:quot;1074d8805eaa79dfec356d34aa719a95quot;, quot;valuequot;:{quot;revquot;:quot;3720758831quot;}}, ...
  39. 39. $ curl 'http://127.0.0.1:5984/ address_book/_all_docs?count=1' {quot;total_rowsquot;:18,quot;offsetquot;:0,quot;rowsquot;:[ {quot;idquot;:quot;1074d8805eaa79dfec356d34aa719a95quot;, quot;keyquot;:quot;1074d8805eaa79dfec356d34aa719a95quot;, quot;valuequot;:{quot;revquot;:quot;3720758831quot;}} ]}
  40. 40. curl 'http://127.0.0.1:5984/address_book/ 1074d8805eaa79dfec356d34aa719a95/' {quot;_idquot;:quot;1074d8805eaa79dfec356d34aa719a95quot; ,quot;_revquot;:quot;3720758831quot;,quot;Fromquot;: {quot;namequot;:quot;Myles Braithwaitequot;,quot;emailquot;:quot;me@mylesbraithwaite .netquot;},quot;Toquot;:quot;tlug@ss.orgquot;,quot;Subjectquot;:quot;Re: [TLUG]: Re: [TLUG-ANNOUNCE]: TLUG Meeting. Tue Sep 9quot;,quot;Datequot;:quot;Wed, 10 Sep 2008 15:28:22 -0400quot;,quot;bodyquot;:quot;...quot;}
  41. 41. $ curl 'http://127.0.0.1:5984/ address_book/ 1074d8805eaa79dfec356d34aa719a95? rev=3720758831'
  42. 42. $ curl 'http://127.0.0.1:5984/ address_book/ 1074d8805eaa79dfec356d34aa719a95? revs=true' {quot;_idquot;:quot;1074d8805eaa79dfec356d34aa719a95quot; ,quot;_revquot;:quot;3720758831quot;, ... quot;_revsquot;: [quot;3720758831quot;,quot;1987563969quot;,quot;3227393092quot;]}
  43. 43. $ curl 'http://127.0.0.1:5984/address_book/_view/ contacts/contact_list/' {quot;total_rowsquot;:5,quot;offsetquot;:0,quot;rowsquot;:[ {quot;idquot;:quot;93a31f6756545d9d59ca53fba6f92fe0quot;,quot;keyquot;:quot;My les Braithwaitequot;,quot;valuequot;: {quot;_idquot;:quot;93a31f6756545d9d59ca53fba6f92fe0quot;,quot;_revquot;:quot; 3685624062quot;,quot;fnquot;:{quot;family- namequot;:quot;Braithwaitequot;,quot;given-namequot;:quot;Mylesquot;},quot;emailquot;: [{quot;valuequot;:quot;me@mylesbraithwaite.netquot;,quot;typequot;:quot;Person alquot;}, {quot;valuequot;:quot;myles@monkeyinyoursoul.comquot;,quot;typequot;:quot;Work quot;}],quot;orgquot;:{quot;organization-namequot;:quot;Monkey in your Soulquot;}}} ...
  44. 44. Use Cases
  45. 45. 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.
  46. 46. Pictures • http://flickr.com/photos/ 83737641@N00/2377691249/ • http://flickr.com/photos/ photonquantique/2596581870/ • http://flickr.com/photos/ mbiddulph/2037845171/ • http://flickr.com/photos/ dragon2309/1490657223/ • http://flickr.com/photos/ malcolmtredinnick/202679799/ • http://flickr.com/photos/cgc/ 130309167/ • http://flickr.com/photos/herzogbr/ 359841353/ • http://flickr.com/photos/ andrewmoir/3012531/ • http://www.flickr.com/photos/ daveaustria/2654190796 • http://flickr.com/photos/irisheyes/ 1160297224/ • http://flickr.com/photos/apesara/ 2499666202/ • http://flickr.com/photos/ jessefriedman/1435220149/ • http://flickr.com/photos/ mehrwert/18711050/ • http://flickr.com/photos/tomnatt/ 2763592134/ • http://flickr.com/photos/ bohemianrabbit/2815366720/ • http://flickr.com/photos/ theo_reth/188334429/ • http://flickr.com/photos/ianturton/ 2155423758/

×