CouchDB 1 CouchDB
Apache CouchDB
CouchDB's Futon Administration Interface, User database Original author(s) Damien Katz, Jan Lehnardt, Noah Slater, Christopher Lenz, J. Chris Anderson
Developer(s) Apache Software Foundation
Initial release 2005
Preview release 1.0.2 / February 1, 2011
Development status Active
Written in Erlang
Operating system Cross-platform
Available in English
Type Document-oriented database
License Apache License 2.0
Website http:/ / couchdb. apache. org/
Apache CouchDB, commonly referred to as CouchDB, is an open source document-oriented database written in the Erlang programming language. It borrows from NoSQL and is designed for local replication and to scale horizontally across a wide range of devices. CouchDB is supported by commercial enterprises CouchBase and Cloudant. CouchDB 2
History In April 2005, Damien Katz (former Lotus Notes developer at IBM; now founder, CTO of CouchBase) posted on his blog about a new database engine he was working on. Details were sparse at this early stage, but what he did share was that it would be a "storage system for a large scale object database" and that it would be called CouchDB (Couch is an acronym for cluster of unreliable commodity hardware).[1] His objectives for the database were for it to become the database of the Internet and that it would be designed from the ground up to serve web applications. CouchDB was originally written in C++, but the project moved to the Erlang OTP platform for its emphasis on fault tolerance. 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 rather than the GPL.[2] On November 2008, it graduated to a top-level project alongside the likes of the Apache HTTP Server, Tomcat and Ant.[3] Currently, CouchDB is maintained at the Apache Software Foundation with backing from IBM. Katz works on it full-time as the lead developer.
Design CouchDB is most similar to other document stores like MongoDB and Lotus Notes. It is not a relational database management system. Instead of storing data in rows and columns, the database manages a collection of JSON documents. The documents in a collection need not share a schema, but retain query abilities via views. Views are defined with aggregate functions and filters are computed in parallel, much like MapReduce. Views are generally stored in the database and their indexes updated continuously, although queries may introduce temporary views. CouchDB supports a view system using external socket servers and a JSON-based protocol.[4] As a consequence, view servers have been developed in a variety of languages. CouchDB exposes a RESTful HTTP API and a large number of pre-written clients are available. Additionally, a plugin architecture allows for using different computer languages as the view server such as JavaScript (default), PHP, Ruby, Python and Erlang. Support for other languages can be easily added. CouchDB design and philosophy borrows heavily from Web architecture and the concepts of resources, methods and representations and can be simplified as the following.
Django may be built for the Web, but CouchDB is built of the Web. I’ve never seen software that so completely embraces the philosophies “behind HTTP. CouchDB makes Django look old-school in the same way that Django makes ASP look outdated. ” [5] —Jacob Kaplan-Moss, Django Developer
It is in use in many software projects and web sites[6] , including Ubuntu, where it is used to synchronize address and bookmark data.[7] Since Version 0.11 CouchDB supports CommonJS' Module specification[8] .
Features Document Storage CouchDB stores documents in their entirety. You can think of a document as one or more field/value pairs expressed as JSON. Field values can be simple things like strings, numbers, or dates. But you can also use ordered lists and associative maps. Every document in a CouchDB database has a unique id and there is no required document schema. ACID Semantics Like many relational database engines, CouchDB provides ACID semantics[9] . It does this by implementing a form of Multi-Version Concurrency Control (MVCC) not unlike InnoDB or Oracle. That means CouchDB can CouchDB 3
handle a high volume of concurrent readers and writers without conflict. Map/Reduce Views and Indexes To provide some structure to the data stored in CouchDB, you can develop views that are similar to their relational database counterparts. In CouchDB, each view is constructed by a JavaScript function (server-side JavaScript by using CommonJS and SpiderMonkey) that acts as the Map half of a MapReduce operation. The function takes a document and transforms it into a single value which it returns. The logic in your JavaScript functions can be arbitrarily complex. Since computing a view over a large database can be an expensive operation, CouchDB can index views and keep those indexes updated as documents are added, removed, or updated. This provides a very powerful indexing mechanism that grants unprecedented control compared to most databases. 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. The biggest gotcha typically associated with this level of flexibility is conflicts. REST API CouchDB treats all stored items (there are others besides documents) as a resource. 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. HTTP is widely understood, interoperable, scalable and proven technology. A lot of tools, software and hardware, are available to do all sorts of things with HTTP like caching, proxying and load balancing.
Examples CouchDB provides a set of RESTful HTTP methods (e.g., POST, GET, PUT or DELETE) by using the cURL lightweight command-line tool to interact with CouchDB server:
curl http:/ / 127. 0. 0. 1:5984/
The CouchDB server processes the HTTP request, it returns a response in JSON as the following:
{"couchdb":"Welcome","version":"1.0.1"}
This is not terribly useful, but it illustrates nicely the way of interacting with CouchDB. Creating a database is simple—just issue the following command:
curl -X PUT http:/ / 127. 0. 0. 1:5984/ wiki
CouchDB will reply with the following message, if the database does not exist:
{"ok":true}
or, with a different response message, if the database already exists:
{"error":"file_exists","reason":"The database could not be created, the file already exists."}
The command below retrieves information about the database:
curl -X GET http:/ / 127. 0. 0. 1:5984/ wiki
The server replies with the following JSON message:
{"db_name":"wiki","doc_count":0,"doc_del_count":0,"update_seq":0, "purge_seq":0,"compact_running":false,"disk_size":79, CouchDB 4
"instance_start_time":"1272453873691070","disk_format_version":5}
The following command will remove the database and its contents:
curl -X DELETE http:/ / 127. 0. 0. 1:5984/ wiki
CouchDB will reply with the following message:
{"ok":true}
Open source components CouchDB includes a number of other open source projects as part of its default package.
Component Description License
SpiderMonkey SpiderMonkey is a code name for the first ever JavaScript engine, written by Brendan Eich at Netscape MPL/GPL/LGPL Communications, later released as open source and now maintained by the Mozilla Foundation. tri-license
jQuery jQuery is a lightweight cross-browser JavaScript library that emphasizes interaction between JavaScript and Dual license: GPL HTML. and MIT
ICU International Components for Unicode (ICU) is an open source project of mature C/C++ and Java libraries MIT License for Unicode support, software internationalization and software globalization. ICU is widely portable to many operating systems and environments.
OpenSSL OpenSSL is an open source implementation of the SSL and TLS protocols. The core library (written in the Apache-like unique C programming language) implements the basic cryptographic functions and provides various utility functions.
Erlang Erlang is a general-purpose concurrent programming language and runtime system. The sequential subset of Modified MPL Erlang is a functional language, with strict evaluation, single assignment, and dynamic typing.
References
[1] Lennon, Joe (2009-03-31). "Exploring CouchDB" (http:/ / www. ibm. com/ developerworks/ opensource/ library/ os-couchdb/ index. html). IBM. IBM. . Retrieved 2009-03-31.
[2] Apache mailing list announcement (http:/ / mail-archives. apache. org/ mod_mbox/ incubator-general/ 200802. mbox/
<3d4032300802121136p361b52ceyfc0f3b0ad81a1793@mail. gmail. com>) on mail-archives.apache.org
[3] Re: Proposed Resolution: Establish CouchDB TLP (http:/ / mail-archives. apache. org/ mod_mbox/ incubator-couchdb-dev/ 200811. mbox/
<3F352A54-5FC8-4CB0-8A6B-7D3446F07462@jaguNET. com>) on mail-archives.apache.org
[4] View Server Documentation (http:/ / wiki. apache. org/ couchdb/ ViewServer) on wiki.apache.org
[5] A Different Way to Model Your Data (http:/ / books. couchdb. org/ relax/ intro/ why-couchdb#A Different Way to Model Your Data)
[6] CouchDB in the wild (http:/ / wiki. apache. org/ couchdb/ CouchDB_in_the_wild) A list of software projects and websites using CouchDB
[7] Email from Elliot Murphy (Canonical) (http:/ / mail-archives. apache. org/ mod_mbox/ couchdb-dev/ 200910. mbox/ <4AD53996.
3090104@canonical. com>) to the CouchDB-Devel list
[8] http:/ / wiki. apache. org/ couchdb/ CommonJS_Modules
[9] (http:/ / couchdb. apache. org/ docs/ overview. html), see section on ACID Properties. CouchDB 5
Bibliography
• Anderson, J. Chris; Slater, Noah; Lehnardt, Jan (November 15, 2009), CouchDB: The Definitive Guide (http:/ /
guide. couchdb. org/ editions/ 1/ en/ index. html) (1st ed.), O'Reilly Media, pp. 300, ISBN 0596158165
• Lennon, Joe (December 15, 2009), Beginning CouchDB (http:/ / www. apress. com/ book/ view/ 9781430272373) (1st ed.), Apress, pp. 300, ISBN 1430272376
• Holt, Bradley (March 7, 2011), Writing and Querying MapReduce Views in CouchDB (http:/ / oreilly. com/
catalog/ 0636920018247) (1st ed.), O'Reilly Media, pp. 76, ISBN 1449303129
External links
• Official website (http:/ / http:/ / couchdb. apache. org/ )
• CouchDB: The Definitive Guide (http:/ / books. couchdb. org/ relax/ )
• CouchDB articles on NoSQLDatabases.com (http:/ / www. nosqldatabases. com/ main/ tag/ couchdb)
• CouchDB green paper (http:/ / manning. com/ free/ green_chandler. html)
• CouchDB news and articles on myNoSQL (http:/ / nosql. mypopescu. com/ tagged/ couchdb)
• Scaling CouchDB (http:/ / nosql. mypopescu. com/ post/ 683838234/ scaling-couchdb)
• Complete HTTP API Reference (http:/ / wiki. apache. org/ couchdb/ Complete_HTTP_API_Reference)
Video links • Erlang eXchange 2008:
• Erlang eXchange 2008: Couch DB at 10,000 feet Jan Lehnardt (http:/ / video. google. com/
videoplay?docid=-3714560380544574985& hl=en#)
• Jan Lehnardt is Giving the Following Talks, CouchDB for Erlang Developers (http:/ / www. erlang-factory. com/
conference/ London2009/ speakers/ janlehnardt)
• CouchDB and Me (http:/ / www. infoq. com/ presentations/ katz-couchdb-and-me) on Jan 31, 2009 by Damien Katz Article Sources and Contributors 6 Article Sources and Contributors
CouchDB Source: http://en.wikipedia.org/w/index.php?oldid=422684132 Contributors: 16@r, 1ForTheMoney, Al3xpopescu, Andy Dingley, Arleyl, Bryant.cutler, Canaima, Cander0000, Centrx, CharlotteWebb, Chiborg, Diannaa, Diego guillen, Dionysostom, Dmccreary, Dstainer, Ehn, Euclidbuena, FatalError, Frap, Gary King, Goldzahn, Gslin, Husky, Jaskiern, Jason Davies, Jncraton, Kenyon, Kinema, Levin, Locotorp, Mentifisto, Micrypt, Mikecron, Miym, Mqtthiqs, MySchizoBuddy, MylesBraithwaite, Nealmcb, Noahslater, Nslater, Palosirkka, Patcito, PhuongCM88, Pingveno, Psychcf, Qwertyus, R'n'B, Rich Farmbrough, Rickyphyllis, SamJohnston, Saric, Seifsallam, Silas S. Brown, Slackr, Spdegabrielle, Suggestednickname, Thumperward, Tmcw, Tobias Bergemann, Tonieisner, Upsetspecial, VanGore, Wikieditoroftoday, 179 anonymous edits Image Sources, Licenses and Contributors
Image:Couchdb-logo.png Source: http://en.wikipedia.org/w/index.php?title=File:Couchdb-logo.png License: Creative Commons Attribution 3.0 Contributors: Damien Katz File:Couchdb screenshot.png Source: http://en.wikipedia.org/w/index.php?title=File:Couchdb_screenshot.png License: Creative Commons Attribution 3.0 Contributors: apache.org License
Creative Commons Attribution-Share Alike 3.0 Unported
http:/ / creativecommons. org/ licenses/ by-sa/ 3. 0/