Chapter 5. MapReduce Views for SQL Users

Many developers who are new to CouchDB are already familiar with relational databases such as MySQL. However, there are some important differences between CouchDB and relational databases. These differences include:

  • There are no tables in a CouchDB database as each document can have its own schema. Since there are no tables, there are also no columns.

  • Views in CouchDB serve a similar role as indexes in a relational database. However, views/indexes are queried directly in CouchDB, whereas in a relational database indexes are used to optimize more generalized queries.

  • A column in a CouchDB result set can contain a mix of logical data types. A column in a result set from a relational database will always contain the same logical data type.

  • CouchDB has no built-in concept of relationships between documents.

  • In CouchDB, related data can be embedded in a document, referenced from a document, or both. These design decisions have important implications.

  • While CouchDB is fully ACID compliant, it does not support transactions across document boundaries.

Although CouchDB has no concept of tables, columns, or rows when it comes to documents, there is one place where columns and rows are applicable: CouchDB views. Every row in a CouchDB view (generated from a Map function) has the same three columns: key (from the first parameter of your call to the emit function), id (the document identifier for the document context from which the emit function was called), ...

Get Writing and Querying MapReduce Views in CouchDB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.