implements key concepts like collation, map/reduce and incremental reduce. It
also acts as a 2-minute CouchDB tutorial. No documents were harmed in this
schema-less JSON documents in a flat namespace.
Each document has an id that's either auto generated
or provided by the user. The JSON documents can be as simple
or as complex as it can be. You can think of each document as
an instance of a particular class. CouchDB
doesn't know or track relationships between documents. It's up
to you to keep track of that.
The sample DB below
contains information about a bunch of pictures uploaded and
tagged by different users with some meta data about each
Now that we have the documents in place, we can use the
map function to generate complex key
value pairs (sorted by key) and then
reduce the values corresponding to each
unique key into either a simple or complex value.
This is a very key concept so it's worth reiterating. The
key/value pairs generated by the
function are stored in a BTree and are updated incrementally
as documents are added or updated. The query against a
view is simply slicing this sorted key space, potentially
reducing the slice and returning the
values. CouchDB will cache the reduced values in the BTree
as well and will try and reuse these cached values during
the key-space slicing, a.k.a. query.
Try and learn: