Questions tagged [couchdb]

Apache CouchDB is a document-oriented database that can be queried and indexed in a MapReduce fashion. It exposes a pure restful API, making interaction possible from any language with the ability to send HTTP requests. This also allows "Futon", the administration interface, to work completely in the browser. It also offers incremental replication with bi-directional conflict detection and resolution.

(all below was copied directly from CouchDB's current wiki)

Introduction

Apache CouchDB is a scalable, fault-tolerant, and schema-free document-oriented database written in Erlang. It's used in large and small organizations for a variety of applications where a traditional SQL database isn't the best solution for the problem at hand. Among other features, it provides:

  • A RESTful HTTP/JSON API accessible from many programming libraries and tools
  • Futon, a browser based GUI and management tool
  • Incremental and flexible replication with conflict management
  • Incremental Map/Reduce queries written in any language (JavaScript support built-in)
  • Excellent data integrity/reliability
  • Native support for BLOBs (Binary Large Objects)
  • Easy installation on many platforms, from servers to mobile devices
  • A strong and active community
  • Good documentation in the form of Books, Presentations, Blog Posts, Wikis, and more

Because the data stored in CouchDB is a JSON document(s), the structure of the data, or document(s), can change dynamically. This feature greatly simplifies the maintenance and development of the database, especially over time when the data and its use evolve. Additionally, CouchDB doesn't rely on SQL JOINS to merge related data. This is often confusing for some users of traditional SQL databases, but is generally a non-issue once CouchDB users become familiar its powerful Map/Reduce framework.

One of CouchDB's most powerful features is its replication framework. This replication framework provides a comprehensive set of features:

  • Master → Slave replication
  • Master ↔ Master replication
  • Filtered Replication
  • Incremental replication with bi-directional conflict detection/resolution

These replication features can be used in combination to create powerful solutions to many problems in the IT industry, like reliability, and scalability. In addition to the fantastic replication features, CouchDB's reliability and scalability is further enhanced by being implemented in the Erlang programming language. Erlang has built-in support for concurrency, distribution, fault tolerance, and has been used for years to build reliable systems in the telecommunications industry. By design, the Erlang language and runtime are able to take advantage of newer hardware with multiple CPU cores. When you look at all of the great characteristics of Erlang, it becomes clear why CouchDB uses it for its foundation.

What it is Not

To better understand what CouchDB is, it may be helpful to understand a few things that CouchDB isn't.

  • A relational database. These differences are articulated above in the Meet CouchDB section, and other portions of this Wiki.
  • A replacement for all databases. When developing and designing a good information system you should select the best tool for the job. While CouchDB can be used in a wide variety of application types, including financial, you may find that a relational database, or other data store, is a better fit for your problem. If you are new to CouchDB, and aren't sure if it's a good fit for your data management problem, please ask others on the mailing list, and the #couchdb IRC channel for advice.
  • An object-oriented database. While CouchDB stores JSON objects, it isn't meant to function as a seamless persistence layer for an OO programming language.

Key Characteristics

Let's review some of the basic elements of CouchDB.

Documents

A CouchDB document is a JSON object that consists of named fields. Field values may be strings, numbers, dates, or even ordered lists and associative maps. An example of a document would be a blog post:

{
    "Subject": "I like Plankton"
    "Author": "Rusty"
    "PostedDate": "5/23/2006"
    "Tags": ["plankton", "baseball", "decisions"]
    "Body": "I decided today that I don't like baseball. I like plankton."
}

In the above example document, Subject is a field that contains a single string value "I like plankton". Tags is a field containing the list of values "plankton", "baseball", and "decisions".

A CouchDB database is a flat collection of these documents. Each document is identified by a unique ID.

Views

To address this problem of adding structure back to semi-structured data, CouchDB integrates a view model using JavaScript for description. Views are the method of aggregating and reporting on the documents in a database, and are built on-demand to aggregate, join and report on database documents. Views are built dynamically and don’t affect the underlying document; you can have as many different view representations of the same data as you like.

Schema-Free

Unlike SQL databases which are designed to store and report on highly structured, interrelated data, CouchDB is designed to store and report on large amounts of semi-structured, document oriented data. CouchDB greatly simplifies the development of document oriented applications, which make up the bulk of collaborative web applications.

In an SQL database, as needs evolve the schema and storage of the existing data must be updated. This often causes problems as new needs arise that simply weren't anticipated in the initial database designs, and makes distributed "upgrades" a problem for every host that needs to go through a schema update.

With CouchDB, no schema is enforced, so new document types with new meaning can be safely added alongside the old. The view engine, using JavaScript, is designed to easily handle new document types and disparate but similar documents.

Distributed

CouchDB is a peer based distributed database system. Any number of CouchDB hosts (servers and offline-clients) can have independent "replica copies" of the same database, where applications have full database interactivity (query, add, edit, delete). When back online or on a schedule, database changes are replicated bi-directionally.

CouchDB has built-in conflict detection and management and the replication process is incremental and fast, copying only documents and individual fields changed since the previous replication. Most applications require no special planning to take advantage of distributed updates and replication.

Unlike cumbersome attempts to bolt distributed features on top of the same legacy models and databases, it is the result of careful ground-up design, engineering and integration. The document, view, security and replication models, the special purpose query language, the efficient and robust disk layout are all carefully integrated for a reliable and efficient system.

Useful links


Books


Related tags :

6131 questions
18
votes
1 answer

Accessing CouchDB Futon on a remote server

I've installed CouchDB on a remote server that I have access to through a terminal telnet/ssh client. The server is running on CentOS6. I really want to be able to work with Futon, but I cannot at the moment because I can only open localhost:5984 in…
user1163278
  • 411
  • 6
  • 20
18
votes
2 answers

Including documents in the emit compared to include_docs = true in CouchDB

I ran across a mention somewhere that doing an emit(key, doc) will increase the amount of time an index takes to build (or something to that effect). Is there any merit to it, and is there any reason not to just always do emit(key, null) and then…
kolosy
  • 3,029
  • 3
  • 29
  • 48
18
votes
3 answers

How do you Schedule Index Updates in CouchDB

As far as I understand, CouchDB indexes are updated when a view is queried. Assuming there are more reads than writes, isn't this bad for scaling? How would I configure CouchDB to update indexes on writes, or better yet, on a schedule?
Jonathan Tran
  • 15,214
  • 9
  • 60
  • 67
18
votes
3 answers

How do I perform a parameterized query on CouchDB

I would like to use CouchDB to store some data for me and then use RESTful api calls to get the data that I need. My database is called "test" and my documents all have a similar structure and look something like this (where hello_world is the…
Mike Farmer
  • 2,992
  • 4
  • 28
  • 32
18
votes
5 answers

How do I DRY up my CouchDB views?

What can I do to share code among views in CouchDB? Example 1 -- utility methods Jesse Hallett has some good utility methods, including function dot(attr) { return function(obj) { return obj[attr]; } } Array.prototype.map = function(func)…
James A. Rosen
  • 64,193
  • 61
  • 179
  • 261
18
votes
5 answers

Atomic transactions in key-value stores

Please excuse any mistakes in terminology. In particular, I am using relational database terms. There are a number of persistent key-value stores, including CouchDB and Cassandra, along with plenty of other projects. A typical argument against them…
ChrisInEdmonton
  • 4,470
  • 5
  • 33
  • 48
17
votes
2 answers

Going back to admin party

I would like to bring my CouchDB instance back to admin party. It is running on localhost, so it is not a security concern. I don't want to reinstall it because I have some databases up and running I'd like to keep. I tried commenting out the admin…
David V
  • 11,531
  • 5
  • 42
  • 66
17
votes
3 answers

Can I create multiple collections per database?

Switching from mongo to pouchdb (with Cloudant), i like the "one database per user" concept, but is there a way to create multiple collections/tables per database ? Example - Peter - History - Settings - Friends - John …
Abel Chalier
  • 629
  • 6
  • 14
17
votes
2 answers

What is the best CouchDB backend for Django?

I am evaluating using CouchDB in my new Django-project. Is there a good database backend in Django for CouchDB? I have tried searching but the projects that turn up seems very small and/or old and I can't make out what parts are solved regarding…
Jonas K
  • 4,215
  • 2
  • 24
  • 25
17
votes
5 answers

Are there any documented projects where CouchDB was tried and rejected?

I keep seeing references to the idea that "CouchDB may not be the best tool in every situation." This is good to know, but unfortunately also applies to every technology. What would be much more helpful is a description of how CouchDB was tried on a…
Rich Apodaca
  • 28,316
  • 16
  • 103
  • 129
17
votes
2 answers

CouchDB: map-reduce in Erlang

How can I write map-reduce functions in Erlang for CouchDB? I am sure Erlang is faster than JavaScript.
edbond
  • 3,921
  • 19
  • 26
17
votes
1 answer

How do create couchdb design docs with Nano in Node.js?

Looking through the README it doesn't look there is a way to create design docs with Nano? What are others doing for this?
timsavery
  • 183
  • 1
  • 6
17
votes
2 answers

How to create a MonoTouch binding from a .framework

I downloaded TouchDB, a "lightweight Apache CouchDB-compatible database engine suitable for embedding into mobile or desktop apps", which gives me a bunch of .framework folders (CouchCocoa.framework, TouchDB.framework and…
Louis Boux
  • 1,228
  • 1
  • 12
  • 26
16
votes
1 answer

CouchDB - trigger code when creating or updating document

I have a page which store data in CouchDB. The page accesses the database directly via javascript, so not much of the logic is hidden from the browser. When creating a new document there is some logic which extracts elements of the data into…
Nippysaurus
  • 20,110
  • 21
  • 77
  • 129
16
votes
3 answers

PouchDB security

What's the best security practice to follow while using PouchDB on the client-side to access a remote server? The example on https://pouchdb.com/getting-started.html syncs with the remote server with the code: var remoteCouch =…
Emre Sokullu
  • 161
  • 1
  • 4