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

CouchDB view is extremely slow

I have a CouchDB (v0.10.0) database that is 8.2 GB in size and contains 3890000 documents. Now, I have the following as the Map of the view function(doc) {emit([doc.Status], doc); And it takes forever to load (4 hours and still no result). Here's…
Chi Chan
  • 11,890
  • 9
  • 34
  • 52
15
votes
4 answers

HBase cassandra couchdb mongodb..any fundamental difference?

I just wanted to know if there is a fundamental difference between hbase, cassandra, couchdb and monogodb ? In other words, are they all competing in the exact same market and trying to solve the exact same problems. Or they fit best in different…
Federico
  • 5,438
  • 5
  • 39
  • 47
15
votes
1 answer

Batch Import of json documents to Apache CouchDb

I have approximately 250,000 JSON-formatted files, each with one object in it (formatted just how CouchDB likes it with _id). What's the best way to import these into my remote CouchDB server as records? -I am on a windows xp machine. -I have…
Nate
  • 331
  • 3
  • 9
15
votes
4 answers

Couchbase-lite and CouchDB

I'm unclear about the requirements for using Couchbase-lite. Is it possible to use Couchbase-lite with CouchDB? Or does Couchbase-lite require Couchbase Server and Sync Gateway? Thanks!
Julian A.
  • 10,928
  • 16
  • 67
  • 107
15
votes
3 answers

Detecting 'unusual behavior' using machine learning with CouchDB and Python?

I am collecting a lot of really interesting data points as users come to my Python web service. For example, I have their current city, state, country, user-agent, etc. What I'd like to be able to do is run these through some type of machine…
sullivanmatt
  • 740
  • 7
  • 15
15
votes
3 answers

CouchDB Query View with Multiple Keys Formatting

I'm having a problem getting a couchdb view to return the proper documents when using multiple keys. This works fine, returning the documents that match: GET http://example.com:5984/myDb/_design/myFilters/_view/getItemByForeignKeyId?key=abc123 This…
J. Lincoln
  • 191
  • 1
  • 2
  • 9
15
votes
6 answers

Is there a lightweight, embeddable, key/value database? (something like diet couchdb)

I was wondering if there was a lightweight, embeddable, key/value database out there. Something like a lightweight Couchdb (RESTful, key/value, etc) where you just send it the key and it responds with appropriate values. Thanks!
vrish88
  • 20,047
  • 8
  • 38
  • 56
14
votes
11 answers

Forgot Username / Pwd to CouchDB

Does anyone know how can I reset the username and password for CouchDB ?
linktoarun
  • 203
  • 1
  • 2
  • 6
14
votes
3 answers

Can I use CouchDB mobile as a replacement for localStorage?

I have an existing web app that runs offline (using HTML5 cache manifest). I am storing data in localStorage. I am going to hit the 5Mb limit for localStorage. Can I use CouchDB as a local db, effectively replacing localStorage with the CouchDB…
Journeyman
  • 10,011
  • 16
  • 81
  • 129
14
votes
1 answer

How to translate from SQL to NoSQL/MapReduce?

I have a background working with relational databases but recently started to dabble in CouchDB and was surprised by how some non-relational operations, which would be simple in SQL, were not first-class functions in CouchDB. I would appreciate you…
sferik
  • 1,795
  • 2
  • 15
  • 22
14
votes
1 answer

null key in from map/reduce result in couchdb

For some reason I'm only getting a null key from map/reduce result in couchdb on mac Result: {"rows":[ {"key":null,"value":2224} ]} Im using couchapp v8.1 and couchdb v1.0.2 My map function is: function(doc) { emit(doc.doc_type, 1); } My…
Up.
  • 959
  • 11
  • 20
14
votes
1 answer

Using map reduce in CouchDB to output fewer rows

Lets say you have two document types, customers and orders. A customer document contains basic information like name, address etc. and orders contain all the order information each time a customer orders something. When storing the documents, the…
Matt
  • 1,811
  • 1
  • 19
  • 30
14
votes
8 answers

Which, if any, of the NoSQL databases can provide stream of *changes* to a query result set?

Which, if any, of the NoSQL databases can provide stream of changes to a query result set? Could anyone point me at some examples? Firstly, I believe that none of the SQL databases provide this functionality - am I correct? I need to be able to…
fadedbee
  • 42,671
  • 44
  • 178
  • 308
14
votes
2 answers

pouchdb db.login is not a function

Tried using these imports import PouchDB from 'pouchdb'; import PouchDBAuth from 'pouchdb-authentication'; PouchDB.plugin(PouchDBAuth) Module ''pouchdb-authentication'' has no default export is the error generated while using these…
shalini
  • 171
  • 1
  • 8
14
votes
3 answers

Unable to send numbers using res.send() using express with node

I am trying to get the "imdb rating" using express in node and I am struggling. movies.json [{ "id": "3962210", "order": [4.361276149749756, 1988], "fields": { "year": 2015, "title": "David and Goliath", "director": "Timothy A.…
Jason
  • 931
  • 2
  • 12
  • 26