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

Is there any way to emit attachment data in a couchdb view

I have found it very useful to use CouchDB attachments when image displaying data on a website. However when I replicate the database to a mobile environment, it's very inefficient to run a view and then have to cycle through the documents to get…
deepwinter
  • 4,568
  • 2
  • 31
  • 37
12
votes
5 answers

Node.js + CouchDB vs CouchDB

I'm questioning myself why should I use combination of Node.js + CouchDB versus CouchDB standalone approach. What are the benefits of getting Node.js into the game? Any comments/experiences are welcome.
Gjorgji Tashkovski
  • 1,948
  • 1
  • 13
  • 14
12
votes
1 answer

Bulk updating a CouchDB database without a _rev value per document?

According to the CouchDB Wiki on PUT operations. To update an existing document, you also issue a PUT request. In this case, the JSON body must contain a _rev property, which lets CouchDB know which revision the edits are based on. If the revision…
edt
  • 22,010
  • 30
  • 83
  • 118
12
votes
1 answer

moving a shard from one bigcouch server to another (for balancing)

I'm currently testing bigcouch for big amounts of data (15 million records daily). When I need to generate views of the data, I experience some balancing problems, because one of my two machines is much weaker than the other one. The result is, that…
andy
  • 1,852
  • 2
  • 20
  • 31
12
votes
2 answers

Bulk loading MongoDB from JSON file with a number of objects

I want to do a bulk load into MongoDB. I have about 200GB of files containing JSON objects which I want to load, the problem is I cannot use the mongoimport tool as the objects contain objects (i.e. I'd need to use the --jsonArray aaram) which is…
NightWolf
  • 7,694
  • 9
  • 74
  • 121
12
votes
2 answers

CouchDb: How to delete documents older > 6 month?

I have the problem that I like to "automagically" delete documents in my couch, which are at least 6 month old. My CouchDb instance runs on a linux server, is there any way to achieve this quite simple (like writing a simple 2-line shell script) ?
Robert Heine
  • 1,820
  • 4
  • 29
  • 61
12
votes
2 answers

Many-to-many relationships in CouchDB or MongoDB

I have an MSSQL database which I am considering porting to CouchDB or MongoDB. I have a many-to-many relationship within the SQL db which has hundreds of thousands rows in the xref table, corresponding to tens of thousands of rows in the tables on…
Journeyman
  • 10,011
  • 16
  • 81
  • 129
12
votes
1 answer

Access Couch DB database URL through rewritten URL, with query parameters

I have my web site run out of a Couch DB instance, so I have my vhost configured to point to /dbname/_design/app/_rewrite. I want to be able to access the index page from a web browser, while still accessing the Couch DB API over Ajax, so I set up a…
Tim Robinson
  • 53,480
  • 10
  • 121
  • 138
12
votes
1 answer

External access for PouchDB, error on sync

I'm creating an app which is pulling data down from a local CouchDB. However when I change the remote db url from localhost:5984 to my ip :5984 so that I can test from my mobile I get the following error when I sync from a remote…
Shardj
  • 1,800
  • 2
  • 17
  • 43
12
votes
2 answers

How do I emulate "sleep" in NodeJS?

I am building a browser game with a mini map of the surroundings of the player. I need to track where other players are and update this mini map whenever someone moves. I am implementing this in NodeJS and CouchDB. My design goes as follows: I…
beatgammit
  • 19,817
  • 19
  • 86
  • 129
12
votes
4 answers

CouchDb read authentication using lists

I am looking into porting a website in CouchDB and it looks very interesting. However, a big problem is that CouchDB does not seem to support read authentication; all documents within a database are accessable by all readers. It is suggested…
Tomas
  • 5,067
  • 1
  • 35
  • 39
12
votes
1 answer

How can I use my sql knowledge with Cloudant/CouchDB?

Some developers who have a good knowledge of querying SQL databases struggle to implement the equivalent query patterns in Cloudant/CouchDB. How can these developers translate their SQL knowledge to Cloudant/CouchDB?
Chris Snow
  • 23,813
  • 35
  • 144
  • 309
12
votes
3 answers

Select top/latest 10 in couchdb?

How would I execute a query equivalent to "select top 10" in couch db? For example I have a "schema" like so: title body modified and I want to select the last 10 modified documents. As an added bonus if anyone can come up with a way to do the…
Andriy Drozdyuk
  • 58,435
  • 50
  • 171
  • 272
12
votes
2 answers

How do I locate CouchDB's local.ini file so I can customize its settings?

I've installed CouchDB (to run a local npm registry) and need to locate the local.ini file so I can customize the couch settings. How do I find the local.ini file?
adamjcooper
  • 1,131
  • 12
  • 24
12
votes
4 answers

CouchDB Java client

This wiki page, http://wiki.apache.org/couchdb/Getting_started_with_Java, lists several CouchDB Java clients. I wonder if any of the clients mentioned is significantly more dominant/popular/better/supported than the others.
Itay Maman
  • 30,277
  • 10
  • 88
  • 118