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

Cassandra, mongodb or couchdb for Ruby on Rails

I think these three are the most popular non-relational db:s out there at this moment. I want to give them a try, but I wonder which one of these are most suitable for Rails when it comes to Gem, documentation and tutorial support. Eg. if I install…
never_had_a_name
  • 90,630
  • 105
  • 267
  • 383
16
votes
4 answers

Querying CouchDB documents between a start date and an end date

I've been trying to figure out how to create a CouchDB view that will let me query all the documents that have a start date greater than A and an end date less than B. Is this possible in CouchDB or another noSQL document store? Should I scrap it…
Erk
  • 161
  • 1
  • 1
  • 3
16
votes
1 answer

Which of CouchDB or MongoDB suits my needs?

Where I work, we use Ruby on Rails to create both backend and frontend applications. Usually, these applications interact with the same MySQL database. It works great for a majority of our data, but we have one situation which I would like to move…
vonconrad
  • 25,227
  • 7
  • 68
  • 69
16
votes
3 answers

PouchDB structure

i am new with nosql concept, so when i start to learn PouchDB, i found this conversion chart. My confusion is, how PouchDB handle if lets say i have multiple table, does it mean that i need to create multiple databases? Because from my…
Sufi
  • 203
  • 3
  • 9
16
votes
3 answers

How to move an element in a sorted list and keep the CouchDb write "atomic"

I have elements of a list in couchdb documents. Let's say these are 3 elements in 3 documents: { "id" : "783587346", "type" : "aList", "content" : "joey", "sort" : 100.0 } { "id" : "358734ff6", "type" : "aList", "content" : "jill", "sort" : 110.0…
user89021
  • 14,784
  • 16
  • 53
  • 65
16
votes
1 answer

Why do my CouchDB databases grow so fast?

I was wondering why my CouchDB database was growing to fast so I wrote a little test script. This script changes an attributed of a CouchDB document 1200 times and takes the size of the database after each change. After performing these 1200 writing…
konrad
  • 409
  • 4
  • 14
16
votes
3 answers

Which CouchDB API to use for Rails?

I am currently investigating possible applications of CouchDB on my current project (written in Rails) and would like to get some feedback from people who have actually used these APIs. Which would you recommend and…
Matt Baker
  • 3,394
  • 3
  • 25
  • 35
16
votes
1 answer

Does the CouchDB cookie have a sliding expiry time?

I'm planning on using CouchDB's built-in cookie authentication for my app (note that this isn't a CouchApp, I'm using a web server between my client and db). So when a user first logs in with their credentials: Credentials are sent to CouchDB from…
isNaN1247
  • 17,793
  • 12
  • 71
  • 118
15
votes
4 answers

Are old data accessible in CouchDB?

I've read a bit about CouchDB and I'm really intrigued by the fact that it's "append-only". I may be misunderstanding that, but as I understand it, it works a bit like this: data is added at time t0 to the DB telling that a user with ID 1's name…
Cedric Martin
  • 5,945
  • 4
  • 34
  • 66
15
votes
3 answers

How to replicate design documents only?

So I want to replicate some changes I made to my design files from dev to production (a.k.a. I want to deploy something). I'm somehow confused since my research did not lead to any concrete results. Although this seams IMHO like a pretty obvious…
Aron Woost
  • 19,268
  • 13
  • 43
  • 51
15
votes
5 answers

Is there a simpler Couchapp than Couchapp?

Specifically, I am finding "evently" to be a bit of a hurdle to getting started with Couchapp. I really like the idea of an App served from CouchDB, but I want to get started without having to figure out "evently" ( which looks very interesting,…
Nick Perkins
  • 8,034
  • 7
  • 40
  • 40
15
votes
3 answers

Amazon S3 architecture

While the post @ http://highscalability.com/amazon-architecture explains Amazon's architecture in general, I am interested in knowing how Amazon S3 is implemented. Some of my guesses are A distributed file system like…
Sukumar
  • 3,502
  • 3
  • 26
  • 29
15
votes
3 answers

Full-text search in Postgres or CouchDB?

I took geonames.org and imported all their data of German cities with all districts. If I enter "Hamburg", it lists "Hamburg Center, Hamburg Airport" and so on. The application is in a closed network with no access to the internet, so I can't access…
Jan L.
  • 151
  • 1
  • 1
  • 3
15
votes
1 answer

Simplify Couchdb JSON response

I'm storing location data in Couchdb, and am looking for a way to get an array of just the values, instead of key: value for every record. For example: The current response {"total rows": 250, "offset": 0, "rows":[ {"id":…
Dick
  • 1,228
  • 13
  • 21
15
votes
2 answers

How do I upload a design document to CouchDB using cURL?

I'm trying to learn CouchDB and I can create views and such in Futon, but I want to write my design documents on the desktop and the upload them using cURL. The 'Definitive Guide' shows updating content documents with cURL but all the design…
Randall Bohn
  • 2,597
  • 2
  • 16
  • 20