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

Sorted String Table (SSTable) or B+ Tree for a Database Index?

Using two databases to illustrate this example: CouchDB and Cassandra. CouchDB CouchDB uses a B+ Tree for document indexes (using a clever modification to work in their append-only environment) - more specifically as documents are modified…
Riyad Kalla
  • 10,604
  • 7
  • 53
  • 56
45
votes
4 answers

Choosing MongoDb/CouchDb/RavenDb - performance and scalability advice

We are looking at a document db storage solution with fail over clustering, for some read/write intensive application. We will be having an average of 40K concurrent writes per second written to the db (with peak can go up to 70,000 during) - and…
amazedsaint
  • 7,642
  • 7
  • 54
  • 83
45
votes
9 answers

Is there any way to create mongodb like _id strings without mongodb?

I really like the format of the _ids generated by mongodb. Mostly because I can pull data like the date out of them client side. I'm planning to use another database but still want that type of _id for my document. How can I create these ids without…
fancy
  • 48,619
  • 62
  • 153
  • 231
43
votes
7 answers

How to get the next letter of the alphabet in Javascript?

I am build an autocomplete that searches off of a CouchDB View. I need to be able to take the final character of the input string, and replace the last character with the next letter of the english alphabet. (No need for i18n here) For Example:…
Dominic Barnes
  • 28,083
  • 8
  • 65
  • 90
42
votes
2 answers

Redis, CouchDB or Cassandra?

What are the strengths and weaknesses of the various NoSQL databases available? In particular, it seems like Redis is weak when it comes to distributing write load over multiple servers. Is that the case? Is it a big problem? How big does a service…
nornagon
  • 15,393
  • 18
  • 71
  • 85
41
votes
3 answers

CouchDB a real world example

Tonight in my daily tech Googling I came across couchDB, after seeing tons of presentations about how it perform ten to hundred times better then any RDBM, how it would save us from SQL languages, tables, primary keys and so much more. I decided…
RageZ
  • 26,800
  • 12
  • 67
  • 76
40
votes
7 answers

Sorting CouchDB Views By Value

I'm testing out CouchDB to see how it could handle logging some search results. What I'd like to do is produce a view where I can produce the top queries from the results. At the moment I have something like this: Example document portion { …
Lee Theobald
  • 8,461
  • 12
  • 49
  • 58
38
votes
6 answers

CouchDB backups and cloning the database

We're looking at CouchdDB for a CMS-ish application. What are some common patterns, best practices and workflow advice surrounding backing up our production database? I'm particularly interested in the process of cloning the database for use in…
Kyle Burton
  • 26,788
  • 9
  • 50
  • 60
37
votes
2 answers

CouchApps and user authentication

I posted a variation of this question to the CouchDB user list and haven't received a response yet. I'm curious to know if anyone else has built a so-called "CouchApp"; a pure HTML/JavaScript application hosted directly within CouchDB. If so, how…
Ryan Duffield
  • 18,497
  • 6
  • 40
  • 40
35
votes
1 answer

CouchDB sorting and filtering in the same view

I'm trying to use CouchDB for a new app, and I need to create a view that sorts by multiple fields and also filters by multiple fields. Here is an example document, I've left out the _id and _rev to save myself some typing. { "title": "My…
Apreche
  • 30,042
  • 8
  • 41
  • 52
35
votes
1 answer

Best way to do one-to-many "JOIN" in CouchDB

I am looking for a CouchDB equivalent to "SQL joins". In my example there are CouchDB documents that are list elements: { "type" : "el", "id" : "1", "content" : "first" } { "type" : "el", "id" : "2", "content" : "second" } { "type" : "el", "id" :…
mit
  • 11,083
  • 11
  • 50
  • 74
35
votes
5 answers

How to Secure CouchDB

CouchDB access as a rest service seems insecure. Anyone can hit the database and delete/add documents once it is exposed. What strategies are there to secure the CouchDB?
steveolyo
  • 439
  • 1
  • 4
  • 8
35
votes
9 answers

How to create a list of unique items in JavaScript?

In my CouchDB reduce function I need to reduce a list of items to the unique ones. Note: In that case it's ok to have a list, it will be a small number of items of string type. My current way is to set keys of a object, then return the keys of that…
user78110
34
votes
7 answers

Serialize and Deserialize Objective-C objects into JSON

I need to serialize and deserialize objective-c objects into JSON to store in CouchDB. Do people have any example code for best practice for a general solution? I looked at a few JSON framework and they are stopped at the NSDictionary/NSArray…
PokerIncome.com
  • 1,708
  • 2
  • 19
  • 30
34
votes
2 answers

Using PouchDB with MongoDB

I've never used CouchDB. I want to use PouchDB on my client app but I'm not sure if it can be integrated with MongoDB because Pouch was designed to be used with CouchDB. Although my API is written in PHP I'm not using any sort of REST API as in…
astroanu
  • 3,901
  • 2
  • 36
  • 50