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
3
votes
2 answers

Does CouchDB support unqiue key constraint?

I come from a RDBMS background, and I have an application here which requires good scalability and low latency. I want to give CouchDB a try. However, I need to detect when a particular INSERT operation fails due to a unique key constraint. Does…
thomas55
  • 891
  • 2
  • 9
  • 12
3
votes
2 answers

CouchDB partial/differential writes

Basic problem I have some large, but logically organised documents - and would like to perform updates on just a sub-section of an individual document. Example Given this simple document: _id: 123456, _rev: 3242342, name: 'Stephen', type:…
isNaN1247
  • 17,793
  • 12
  • 71
  • 118
3
votes
2 answers

Map-Reduce Query to Count Tags

I have a database of documents which are tagged with keywords. I am trying to find (and then count) the unique tags which are used alongside each other. So for any given tag, I want to know what tags have been used alongside that tag. For example,…
Dave
  • 4,356
  • 4
  • 37
  • 40
3
votes
1 answer

copy from old database to new database in Couchdb

I am working on a project which uses couchdb. Actually before I was working with the database which has 1000 of documents, and now I have moved to new database it's also has many new documents than other's. If I copy all documents one by one it will…
shashank
  • 35
  • 6
3
votes
1 answer

dates in couchdb

How do you insert dates in couchdb? As strings? I have couchdb-1.0.3. 1. I did this: $ curl -X PUT 127.0.0.1:5984/misc/doc1 -d '{"date":"2011-13-01T17:30:12+01:00"}' This works, but this date doesn't exists. 2. I thought I had to do this: $ curl…
ericj
  • 2,138
  • 27
  • 44
3
votes
2 answers

Multi Hosting Quota on CouchDB

I am looking to offer some free hosting for CouchDB. The authorization part is fairly straightforward (user has access to 1 database) but I was wondering if there is any simple way to assign a space quota for that database/user.
devnull
  • 2,752
  • 1
  • 21
  • 38
3
votes
1 answer

When to create a new document in NoSQL

I've just starting out with NoSQL (in my case CouchDB) and can't seem to answer what I believe should be a simple question, on what the common practice is around creating a new document vs. appending data to an existing one. I currently have a…
isNaN1247
  • 17,793
  • 12
  • 71
  • 118
3
votes
1 answer

Talking to remote CouchDB server from Android

I'm designing a turn based game similar to Words With Friends. I don't need the data to be stored persistently on the phone in a local CouchDB. I've attempted HTTP requests using HttpPut/HttpGet and HttpClient with no success. What is the best way…
SemperFly
  • 1,563
  • 3
  • 17
  • 31
3
votes
1 answer

Couch DB installation not working on Mac OSx Lion

I had a problem installing Couch DB on mac OSx Lion using Homebrew. I execute the command brew install couchdb but then I have have a problem with mmd5 on file ~/Library/Caches/Homebrew/spidermonkey-1.8.5.tar.gz How can I proceed?
Marcin Wasiluk
  • 4,675
  • 3
  • 37
  • 45
3
votes
0 answers

Analyzer not found performing query string over elasticsearch couchdb river

Pretty sure that I'm doing some huge mistake, but I have no clue how to sort it. My couchdb river and my index are defined as following: curl -XPUT 'localhost:9200/_river/my_index/_meta' -d '{ "type" : "couchdb", "couchdb" : { "host" :…
Klerisson
  • 312
  • 1
  • 2
  • 17
3
votes
1 answer

Inverted Index possible from couchdb view?

Suppose I have couchdb docs that look like so: { "_id": "id", "_rev": "rev", "title": "foobar", "URI": "http://www.foobar.com", "notes": "", "date": 1334177254774, "tags": [ "tag1", "tag2", "tag3" …
Geoff Moller
  • 778
  • 7
  • 15
3
votes
3 answers

Need a CouchDB trick to sort by date and filter by group

I have documents with fields 'date' and 'group'. And this is my view: byDateGroup: { map: function(doc) { if (doc.date && doc.group) { emit([doc.date, doc.group], null); } } } What would be the equivalent query of this: select *…
Pankaj Jangid
  • 524
  • 3
  • 18
3
votes
2 answers

CouchDB reduce function with an array of values

I have a map function that returns a value as an array: emit(doc.created_date, { calories : doc.calories, miles : doc.miles, minutes : doc.minutes, reps : doc.reps, steps : doc.steps, water : doc.water }) I want to run a sum on the calories, miles,…
Milimber
  • 31
  • 1
  • 2
3
votes
1 answer

CouchDB on Virtual Server

I'm writing a web application which basically searches your Twitter timeline for links. I used to use MongoDB for saving tweets and information, which worked fine on my dev system, but crashed after some time on a virtual server during tests. I know…
Hamrath
  • 33
  • 2
3
votes
1 answer

How do I use a CouchDB username in a URL rewrite?

I have a list function that can be accessed like this: _list/characters/characters_by_user?startkey=["org.couchdb.user:rodriguez"]&endkey=["org.couchdb.user:rodriguez", {}] I'm attempting to rewrite the URL so you can access it in a friendlier…
Matt Norris
  • 8,596
  • 14
  • 59
  • 90