hank / life

Good code.

This URL has Read+Write access

life / oscon / 2008 / sessions / CouchDB.rdoc
dee801b6 » Erik 2008-07-24 Mods to some notes 1 = OSCON 2008, Session 1: CouchDB
6c3381ca » Erik 2008-07-23 Adding couchdb talk 2
3 == RDBMS
4 - CouchDB is not a relational database.
5 - Usually you design a schema up front
6
7 == What is CouchDB
8 - Stores *Documents* (individual data records)
9 - <i>No Schema!</i>
10 - Columns containing NULL don't make sense
11 - "My Business card doesn't have 'Fax Number:' and then NULL"
12 - Natural data behavior
13
14 == Documents
15 - Store your document data in a JSON string.
16 - Talked about how Ruby is basically JSON compatible with no translations
17 - XML Sucks.
18
19 Short example:
20 {
21 "_id":"223BDCD",
22 "_rev":"834BC",
23 "age":54,
24 "name":"Darth Vader",
25 ...
26 }
27
28 - Revision allows you to fetch the document, write a new copy, and save it as the latest revision of the document. This allows you to turn back time per database row!
29
30 == How do I talk to it?
31
32 === HTTP REST API
33 - Create: HTTP PUT /db/docid
34 - Read: HTTP GET /db/docid
35 - Update: HTTP POST /db/docid
36 - Delete: HTTP DELE /db/docid
37
38 - The ID does not have to be generated by the user. Just don't provide one. If you provide one, it has to be a string.
39 - JSON doesn't deal with binary data, you have to BASE64 encoding. There apparently is some other way to handle it.
40 - If you don't have well-formed JSON, all calls will result in an error. They don't have a way to specify a way to enforce writes.
41 - Type integrity checking: They don't care.
42 - Is there a way to get a document using something other than an id? Yes.
43
44 There are 2 more features that make Couch really cool:
45
46 == Views
47 - Filter, Collate, Aggregate
48 - Powered by map/reduce! (They improved it a little bit!)
49 - Views are built incrementally and on demand. Reduction is optional.
50 - Sends diffs around to sync db data. <b>VERY FAST!</b>
51 - No write penalty with views.
52 - The view is simply the result of a map/reduce function stored in a btree.
53
54 === Example: Tag Cloud
55 - We have a db full of tagged documents
56 - We must know how often each tag appears
57 - Use map/reduce!
58 - Works well since it's in Erlang, which can be massively parallel
59
60 == Replication
61 - CouchDB was originally designed for an offline replication of your database.
62 - Replication works a lot like rsync
63 - They don't use auto_increment
64 - Full new revisions of documents, not partial changes.
65
66 == Built for the future
67 - Written in Erlang.
68 - Non-locking MVCC and ACID compliant data store
69 - No locking of the data store ever
70 - Damien Katz invented it. Self-funded fulltime development for 2 years.
71 - Now it's backed by IBM.
72
73