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

Pros and Cons of CouchDB

I'm looking at using CouchDB as a backend of an ASP.NET web API/web app which uses JSON heavily. I'm interested in the pros and cons in terms of: replication platform dependency (currently all our servers are Windows 2003) ease of use (are there…
KlsLondon
  • 1,160
  • 1
  • 9
  • 18
3
votes
2 answers

CouchDB document design for facebook insights

I am starting to work on CouchDB for collecting analytical information from Facebook Insights and other sources. I am not sure about a proper design of a document and would like more experienced CouchDB users to see it and warn me if I am about to…
3
votes
1 answer

couchdb replication on a lot of servers

I am currently looking at CouchDB and I understand that I have to specify all the replications by hand. If I want to use it on 100 nodes how would I do the replication? Doing 99 "replicate to" and 99 "replicate from" on each node It feels like it…
Simon Levesque
  • 417
  • 1
  • 6
  • 13
3
votes
1 answer

Select a record where value is max in CouchDB

I have a couchdb database with 156 json documents. I want to find the max of a certain value in the documents and then emit the whole document that contains that maximun value. I used this code but it doesnt seem to work. This may help you…
user1521626
  • 41
  • 1
  • 5
3
votes
4 answers

How to get the rank for a student-score document?

My document structure in CouchDB looks like below: { "_id": "0a68cdbe4a7f3abf4046bc", "_rev": "1-1508", "score": {"math":90, "physics": 88, "chemistry": 60}, "student_name": "Mike" } I need to show below stats in the front end to setup a…
greeness
  • 15,956
  • 5
  • 50
  • 80
3
votes
1 answer

Can I override the Json.Net member-name mapping, within the context of a single serializer?

I'm trying to write documents into CouchDB in .NET, but my I don't want to mark all of my Id properties with [JsonProperty(MemberName = "_id")], since I need to serialize them normally (with the member name being Id) to send them out via my own HTTP…
John Gietzen
  • 48,783
  • 32
  • 145
  • 190
3
votes
2 answers

Couchdb: relational database capabilities

Let's assume that I have a list of 239800 documents like the following: { name: somename, data:{age:someage, income:somevalue, height:someheight, dumplings_consumed:somenumber} } I know that I can index the doc by doc.data.age,…
Oo.oO
  • 33
  • 3
3
votes
2 answers

Searching in couchdb or do river thru an elastic search

I understand we create views on couchdb and then we can search. Another interesting approach is to connect couchdb with elasticsearch thru river and search in elasticsearch. I have two questions: in terms of disk space usage, will elasticsearch be…
dvail
  • 381
  • 2
  • 12
3
votes
1 answer

How can I embed TouchDB in a phonegap html5 app?

Basically I want the sync feature of CouchDB while developing with HTML5 and package the app with phonegapp. I see that couchbase mobile has a few drawbacks(large code size, long startup time) and TouchDB seems promising. However, I can't find an…
blurrcat
  • 1,278
  • 13
  • 23
3
votes
1 answer

Error in executing bulk Update in Cloudant CouchDB using Ektorp ExecuteBulk () and ExecuteAllOrNothing () API

I am facing an issue with Bulk Update on a list of documents in Cloudant DB (CouchDB) using Ektorp executeBulk & ExecuteAllOrNothing functions. For couchDbConnector.executeAllOrNothing(List list), I am getting error as…
Rahul Mohan
  • 101
  • 1
  • 2
  • 6
3
votes
1 answer

490KB insert crashes BigCouch

I have a BigCouch cluster with Q=256, N=3, R=2, W=2. Everything seems to be up and running and I can read and write small test documents. The application is in Python and uses the CouchDB library. The cluster has 3 nodes, each on CentOS on vxware…
user634943
  • 101
  • 1
  • 4
3
votes
1 answer

CouchDB Server Fails To Start

All of a sudden I can't get the CouchDB Server to start on my Mac (OS 10.8.2). It seemed to die for no reason and now it won't start, even after a reboot. UPDATE: I'm using v1.2.0. Here's the error log. I searched for 'eaddrnotavail' but didn't find…
Brad Rhoads
  • 1,828
  • 3
  • 29
  • 52
3
votes
1 answer

Replicate data from CouchDB to PouchDB for offline storage on windows 7 using google Chrome V22

I am trying to replicate data from CouchDB to PouchDB for offline storage using the code to pull data from CouchDB: db.replicate.from('http://test.iriscouch.com/todo','idb://todo', function (err, changes) { if (err) { console.log(err); } else { …
qorsmond
  • 1,246
  • 1
  • 18
  • 29
3
votes
1 answer

Getting all documents of a database in CouchDB

The get() method of the Cradle library requires me to provide an _id. CouchDB provides an _all_docs view, but there's nothing in the Cradle documentation about this. How can I get all documents from a single CouchDB database with Cradle?
user1684434
  • 49
  • 1
  • 2
3
votes
1 answer

Cannot add design documents (beginning with "_") in CouchDB

When I try to add design documents (beginning with "_") I get an error "Only reserved document ids may start with underscore." How can I add a design document?
Andrew Campoli
  • 222
  • 1
  • 13