Saturday, December 14, 2013


From Wikipedia, the free encyclopedia
Apache CouchDB
Couchdb screenshot.png
CouchDB's Futon Administration Interface, User database
Original author(s)Damien Katz, Jan Lehnardt, Noah Slater, Christopher Lenz, J. Chris Anderson, Paul Davis, Adam Kocoloski, Jason Davies, BenoƮt Chesneau, Filipe Manana, Robert Newson
Developer(s)Apache Software Foundation
Initial release2005
Stable release1.5.0 / November 5, 2013
Development statusActive
Written inErlang
Operating systemCross-platform
TypeDocument-oriented database
LicenseApache License
The LYCE (software bundle) is based on Erlang and comprises CouchDB. It's entirely composed of free and open-source software
Apache CouchDB, commonly referred to as CouchDB, is an open source database that focuses on ease of use and on being "a database that completely embraces the web".[1] It is a NoSQL database that uses JSON to store data, JavaScript as its query language using MapReduce, and HTTP for an API.[1] One of its distinguishing features is multi-master replication. CouchDB was first released in 2005 and later became an Apache project in 2008.
Unlike in a relational database, CouchDB does not store data and relationships in tables. Instead, each database is a collection of independent documents. Each document maintains its own data and self-contained schema. An application may access multiple databases, such as one stored on a user's mobile phone and another on a server. Document metadata contains revision information, making it possible to merge any differences that may have occurred while the databases were disconnected.
CouchDB implements a form of Multi-Version Concurrency Control (MVCC) in order to avoid the need to lock the database file during writes. Conflicts are left to the application to resolve. Resolving a conflict generally involves first merging data into one of the documents, then deleting the stale one.[2]
Other features include document-level ACID semantics with eventual consistency, (incremental) MapReduce, and (incremental) replication. Administration is supported with a built-in web application called Futon.


CouchDB (Couch is an acronym for cluster of unreliable commodity hardware)[3] is a project created in April 2005 by Damien Katz, formerLotus Notes developer at IBM. Damien Katz defined it as a "storage system for a large scale object database". His objectives for the database were to become the database of the Internet and that it would be designed from the ground up to serve web applications. He self-funded the project for almost two years and released it as an open source project under the GNU General Public License.
In February 2008, it became an Apache Incubator project and the license was changed to the Apache License.[4] A few months after, it graduated to a top-level project.[5] This led to the first stable version being released in July 2010.[6]
In early 2012, Damien Katz left the project to focus on Couchbase Server.[7]
Since the departure of Damien Katz, the Apache CouchDB project has continued, releasing 1.2 in April 2012 and 1.3 in April 2013. In July 2013, the CouchDB community merged the codebase for BigCouchCloudant's clustered version of CouchDB, into the Apache project. The BigCouch clustering framework is prepared to be included in an upcoming release of Apache CouchDB.[8]

Main features[edit]

Document Storage
CouchDB stores data as "documents", as one or more field/value pairs expressed as JSON. Field values can be simple things like strings, numbers, or dates; but ordered lists and associative arrays can also be used. Every document in a CouchDB database has a unique id and there is no required document schema.
ACID Semantics
CouchDB provides ACID semantics.[9] It does this by implementing a form of Multi-Version Concurrency Control, meaning that CouchDB can handle a high volume of concurrent readers and writers without conflict.
Map/Reduce Views and Indexes
The stored data is structured using views. In CouchDB, each view is constructed by a JavaScript function that acts as the Map half of a map/reduce operation. The function takes a document and transforms it into a single value which it returns. CouchDB can index views and keep those indexes updated as documents are added, removed, or updated.
Distributed Architecture with Replication
CouchDB was designed with bi-direction replication (or synchronization) and off-line operation in mind. That means multiple replicas can have their own copies of the same data, modify it, and then sync those changes at a later time.
All items have a unique URI that gets exposed via HTTP. REST uses the HTTP methods POST, GET, PUT and DELETE for the four basic CRUD (Create, Read, Update, Delete) operations on all resources.
Eventual Consistency
CouchDB guarantees eventual consistency to be able to provide both availability and partition tolerance.
Built for Offline
CouchDB can replicate to devices (like smartphones) that can go offline and handle data sync for you when the device is back online.
CouchDB also offers a built-in administration interface accessible via web called Futon.[10]

Use cases & production deployments[edit]

Replication and synchronization capabilities of CouchDB make it ideal for using it in mobile devices, where network connection is not guaranteed but the application must keep on working offline.
CouchDB is well suited for applications with accumulating, occasionally changing data, on which pre-defined queries are to be run and where versioning is important (CRM, CMS systems, by example). Master-master replication is an especially interesting feature, allowing easy multi-site deployments.[11]

Enterprises that use CouchDB[edit]

A few examples of enterprises that used or are using CouchDB are:
  • Ubuntu began using it in 2009 for its synchronization service "Ubuntu One"[12] but stopped using it in November 2011.[13]
  • The BBC, for its dynamic content platforms[14]
  • Credit Suisse, for internal use at commodities department for their marketplace framework.[15]
  • Meebo, for their social platform (web and applications) - Meebo was acquired by Google and was shut down on July 12, 2012.
A more comprehensive list of software projects and web sites that use CouchDB is available on the Apache projects's wiki[16][15]

Data manipulation: documents and views[edit]

CouchDB manages a collection of JSON documents. The documents are organised via views. Views are defined with aggregate functions and filters are computed in parallel, much likeMapReduce.
Views are generally stored in the database and their indexes updated continuously. CouchDB supports a view system using external socket servers and a JSON-based protocol.[17] As a consequence, view servers have been developed in a variety of languages (JavaScript is the default, but there are also PHP, Ruby, Python and Erlang).

Accessing data via HTTP[edit]

Applications interact with CouchDB via HTTP. The following demonstrates a few examples using cURL, a command-line utility. These examples assume that CouchDB is running on localhost( on port 5984.
Accessing server information
  "couchdb": "Welcome",
Creating a database named wiki
curl -X PUT
{"ok": true}
Attempting to create a second database named wiki
curl -X PUT
  "reason":"The database could not be created, the file already exists."
Retrieve information about the wikidatabase
  "db_name": "wiki",
  "doc_count": 0,
  "doc_del_count": 0,
  "update_seq": 0,
  "purge_seq": 0,
  "compact_running": false,
  "disk_size": 79,
  "instance_start_time": "1272453873691070",
  "disk_format_version": 5
Delete the database wiki
curl -X DELETE
{"ok": true}
Create a document, asking CouchDB to supply a document id
curl -X POST -H "Content-Type: application/json" --data \
'{ "text" : "Wikipedia on CouchDB", "rating": 5 }' \
  "ok": true,
  "id": "123BAC",
  "rev": "946B7D1C"

Open source components[edit]

CouchDB includes a number of other open source projects as part of its default package.
SpiderMonkeySpiderMonkey is a code name for the first ever JavaScript engine, written by Brendan Eich at Netscape Communications, later released as open source and now maintained by the Mozilla Foundation.MPL
jQueryjQuery is a lightweight cross-browser JavaScript library that emphasizes interaction between JavaScript and HTML.Dual license:GPL and MIT
ICUInternational Components for Unicode (ICU) is an open source project of mature C/C++ and Java libraries for Unicode support, software internationalization and software globalization. ICU is widely portable to many operating systems and environments.MIT License
OpenSSLOpenSSL is an open source implementation of the SSL and TLS protocols. The core library (written in the C programming language) implements the basiccryptographic functions and provides various utility functions.Apache-like unique
ErlangErlang is a general-purpose concurrent programming language and runtime system. The sequential subset of Erlang is a functional language, with strict evaluationsingle assignment, and dynamic typing.Modified MPL

No comments: