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
13
votes
1 answer

CouchDB "Join" two documents

I have two documents that looks a bit like so: Doc { _id: AAA, creator_id: ..., data: ... } DataKey { _id: ..., credits_left: 500, times_used: 0, data_id: AAA } What I want to do is create a view which would allow me to pass the…
Obto
  • 1,377
  • 1
  • 20
  • 33
13
votes
3 answers

CouchDB create database per document type?

I've just started playing around with couchdb and I'm really liking it so far, but I was wondering when you should be creating a new database. Here's what I mean: If i were to create a blog on a server with multiple blogs and this was a RDBMS, I'd…
Obto
  • 1,377
  • 1
  • 20
  • 33
13
votes
1 answer

How to pass two parameter values to couchdb views?

I want to reproduce this SQL in CouchDB views. SELECT name,department FROM Persons where id = ? and group_id = ? ; How do I write a view and query view in CouchDB for this SQL?
Ajay
  • 151
  • 1
  • 1
  • 6
13
votes
2 answers

Changing user name and password in CouchDB _user database

I am using jquery.couch.js to do signup/login/logout to a CouchDB _users database in my Sproutcore application. Is anyone aware of a method for changing user _id and password?
Logic Artist
  • 1,006
  • 11
  • 23
13
votes
1 answer

When do I use a separate CouchDB database?

I'm designing a system based around CouchDB. It will have a handful of different components - a list of users, a main data store, logging, etc. What I want to get a feel for is, what should the scope of a CouchDB database be? Should I have separate…
stompydan
  • 233
  • 1
  • 7
13
votes
2 answers

How to do partial update of a document

I need a guidance on how can I update a field in CouchDB. I tried curl via console it works fine but programatically. I don't understand how to update a particular field say 'name'. Here is the snippet of updating a document in CouchDB which works…
Jitesh
  • 269
  • 1
  • 6
  • 19
13
votes
1 answer

Deleting document attachments in CouchDb

In CouchDb's documentation, the described method of deleting document attachments is to send a DELETE call to the attachment's url. However, I have noticed that if you edit the document and remove the attachment stub from the _attachment field, it…
Henrik Barratt Due
  • 5,614
  • 1
  • 21
  • 22
13
votes
2 answers

UUIDs in CouchDB

I am wondering about the format UUIDs are by default represented in CouchDB. While the RFC 4122 describes UUIDs like 550e8400-e29b-11d4-a716-446655440000, CouchDB uses continuously chars like 3069197232055d39bc5bc39348a36417. I've searched some time…
b_erb
  • 20,932
  • 8
  • 55
  • 64
13
votes
1 answer

How to answer an apt-get configuration change prompt on Travis-CI, in this case for couchdb 1.5.0

I am trying run a specific version of couchdb on travis-ci I do this by following the offical apt-get instructions from couchdb Part of the installation is a prompt for what to do with an old configuration file. See the following: Installing new…
Victory
  • 5,811
  • 2
  • 26
  • 45
13
votes
3 answers

Does CouchDB supports referential integrity?

I am new to CouchDB and learning about it. I did not come across CouchDB support for referential integrity. Can we create a foreign key for a field in the CouchDB document? For e.g. Is it possible to ensure a vendor name used in a order document is…
Sundar
  • 1,204
  • 1
  • 14
  • 17
13
votes
4 answers

Selective replication with CouchDB

I'm currently evaluating possible solutions to the follwing problem: A set of data entries must be synchonized between multiple clients, where each client may only view (or even know about the existence of) a subset of the data. Each client "owns"…
FRotthowe
  • 3,662
  • 25
  • 31
13
votes
1 answer

How to resolve conflicts with continuous replication

I'm new to both CouchDB and PouchDB and am using it to create a contact management system that syncs across mobile and desktop devices, and can be used offline. I am seeing that using PouchDB is infinitely easier than having to write a PHP/MySQL…
Colin Skow
  • 1,006
  • 12
  • 21
13
votes
1 answer

Modeling relationships on CouchDB between documents?

I'm trying to model a fairly simple relationship in CouchDB and I'm having trouble determining the best way to accomplish this. I'd like users to be able to create lists of video game objects. I have the video game documents stored in the DB already…
dstaley
  • 1,002
  • 1
  • 12
  • 32
13
votes
1 answer

How exactly is startkey and endkey working in CouchDB?

I'm working with a locations database in CouchDB. I created a view where my key is an array with rounded values of latitude and longitude. Now I'm selecting with the following conditions: Startkey: [ 52.34, 4.883 ] Endkey: [ 52.37, 4.903 ] Here I…
Lumocra
  • 545
  • 2
  • 6
  • 16
13
votes
6 answers

CouchDB multiple tags

Is there any way to have multiple tag search implemented in CouchDB? I have documents (posts) each with multiple tags. I need to find posts that have been tagged with an arbitrary set of tags. How do I do it? I could of course do it with multiple…
Vagmi Mudumbai
  • 613
  • 8
  • 14