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
22
votes
4 answers

How to rename a CouchDB database?

I don't see an API for renaming a CouchDB database, or an option in Futon to do the same. Short of replicating to another database and then deleting the original, is there a one-step way to rename a database?
tephyr
  • 1,001
  • 2
  • 14
  • 26
21
votes
2 answers

System.Net.Http.HttpClient caching behavior

I'm using HttpClient 0.6.0 from NuGet. I have the following C# code: var client = new HttpClient(new WebRequestHandler() { CachePolicy = new…
NiklasN
  • 559
  • 1
  • 7
  • 12
21
votes
4 answers

Isn't HTTP verb PUT used for updating and not creating content?

In CouchDB, to create a new document you send: PUT /albums/70b50bfa0a4b3aed1f8aff9e92dc16a0 Isn't PUT used to update data and not creating it?
never_had_a_name
  • 90,630
  • 105
  • 267
  • 383
21
votes
2 answers

How to run more than one app on one instance of EC2

I have a couple of small production sites and a bunch of fun hobbyist/experimental apps and such. I'd like to run all of them on one EC2 instance. Can I install node.js, npm, express and couchdb once, and then run each app on a different port, and…
Costa Michailidis
  • 7,691
  • 15
  • 72
  • 124
20
votes
1 answer

CouchDB Reduce Check Box in Futon

I created a small test database in CouchDB and I'm creating a temporary view in Futon. I wrote the mapper and the reducer. The mapper works, but the check box for the reducer never shows up. I know that there should be a check box because I've seen…
Jason Marcell
  • 2,785
  • 5
  • 28
  • 41
20
votes
4 answers

CouchDB view throwing invalid UTF-8 JSON error when using key, startkey

I have a VERY basic view defined in CouchDB: function(doc) { if(doc.date && doc.erc) { emit(doc.date, doc.erc); } } It simply pulls ALL documents and sorts by dates. I've tried appending ?startkey="2010-05-01" to the URL and Futon just…
Jim Wharton
  • 1,375
  • 3
  • 18
  • 41
20
votes
3 answers

Couchdb Mango Performance vs Map Reduce Views

I've just noticed that in the release notes of Couchdb 2.0, it is mentionned that Mango queries are recommended for new applications. It is also mentionned that apparently Mango indexes are from 2x to x10 faster than javascript queries which really…
tobiak777
  • 3,175
  • 1
  • 32
  • 44
20
votes
4 answers

Connect to Cloudant CouchDB with Node.js?

I am trying to connect to my CouchDB database on Cloudant using Node.js. This worked on the shell: curl https://weng:password@weng.cloudant.com/my_app/_all_docs But this node.js code didn't work: var couchdb = http.createClient(443,…
ajsie
  • 77,632
  • 106
  • 276
  • 381
20
votes
4 answers

Eventual Consistency

I am in the early stages of design of an application that has to be highly available and scalable. I want to use an eventual consistency data model for this for a number of reasons. I know and understand why this is an unpopular architectural choice…
JimboV
20
votes
5 answers

What database systems should a startup company consider?

Right now I'm developing the prototype of a web application that aggregates large number of text entries from a large number of users. This data must be frequently displayed back and often updated. At the moment I store the content inside a MySQL…
Roman
  • 10,309
  • 17
  • 66
  • 101
20
votes
3 answers

Which PHP library I should choose to work with CouchDB?

I want to try playing with CouchDB for a new project I'm writing (as a hobby, not part of my job). I'm well versed in PHP, but I haven't programmed with CouchDB at all, and also I have little experience with non-SQL databases. From looking at…
Guss
  • 30,470
  • 17
  • 104
  • 128
20
votes
3 answers

Mobile app using PouchDB-CouchDB and MySQL

I'm developing a mobile app wrapped in Cordova that runs alongside our web-based application, based on PHP & MySQL. The mobile app uses local-storage & gets data via a layer of services that have been written to exchange data between the mobile app…
trace
  • 361
  • 1
  • 4
  • 9
20
votes
4 answers

SQLite-like alternative for MongoDB?

I'm looking for a document-oriented db with a Ruby API that has SQLite-like properties: self-contained, serverless, zero-configuration. Are there light alternatives to MongoDB or CouchDB? Is RDDB a possibility? If not, what are the best paths to…
davidbe
  • 840
  • 1
  • 6
  • 16
20
votes
9 answers

how to add cors in couchDB -- No 'Access-Control-Allow-Origin' header is present on the requested resource

I am trying to create a html file which synchronize data from a pouchDb to couchDb ..but iam getting the following error in chrome console. Uncaught TypeError: Cannot call method 'addEventListener' of null OPTIONS http://localhost:5984/todos/ 405…
ess
  • 663
  • 3
  • 9
  • 17
20
votes
2 answers

CouchDB cURL Windows Command Line Invalid JSON

Running the following command from a Windows command line using cURL attempting to post a new document to an existing CouchDB database (named test) fails: curl -H "Content-Type: application/json" -X POST "http://127.0.0.1:5984/test" -d…
skinneejoe
  • 3,921
  • 5
  • 30
  • 45