Apache CouchDB explained

Apache CouchDB
Logo Size:100px
Screenshot Size:300px
Author:Damien Katz, Jan Lehnardt, Naomi Slater, Christopher Lenz, J. Chris Anderson, Paul Davis, Adam Kocoloski, Jason Davies, Benoît Chesneau, Filipe Manana, Robert Newson
Developer:Apache Software Foundation
Programming Language:Erlang, JavaScript, C, C++
Operating System:Cross-platform
Genre:Document-oriented database
License:Apache License 2.0

Apache CouchDB is an open-source document-oriented NoSQL database, implemented in Erlang.

CouchDB uses multiple formats and protocols to store, transfer, and process its data. It uses JSON to store data, JavaScript as its query language using MapReduce, and HTTP for an API.[1]

CouchDB was first released in 2005 and later became an Apache Software Foundation project in 2008.

Unlike a relational database, a CouchDB database 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 multiversion concurrency control (MVCC) so it does not 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. One of CouchDB's distinguishing features is multi-master replication, which allows it to scale across machines to build high-performance systems. A built-in Web application called Fauxton (formerly Futon) helps with administration.

History

Couch is an acronym for cluster of unreliable commodity hardware.[3] The CouchDB project was created in April 2005 by Damien Katz, a former Lotus Notes developer at IBM. 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 was offered under the Apache License instead.[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, Katz left the project to focus on Couchbase Server.[7]

Since Katz's departure, 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 BigCouch, Cloudant's clustered version of CouchDB, into the Apache project.[8] The BigCouch clustering framework is included in the current release of Apache CouchDB.[9]

Native clustering is supported at version 2.0.0. And the new Mango Query Server provides a simple JSON-based way to perform CouchDB queries without JavaScript or MapReduce. Also in version 2.0.0 was the introduction of Fauxton, the new built-in web interface, to replace Futon, the old built-in web interface.[10]

Main features

ACID Semantics
  • CouchDB provides ACID semantics.[11] 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.
    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.
    Distributed Architecture with Replication
  • CouchDB was designed with bi-directional 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.
    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.
    Eventual Consistency
  • CouchDB guarantees eventual consistency to be able to provide both availability and partition tolerance.
    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 that it returns. CouchDB can index views and keep those indexes updated as documents are added, removed, or updated.
    HTTP API
  • All items have a unique URI that gets exposed via HTTP. It uses the HTTP methods POST, GET, PUT and DELETE for the four basic CRUD (Create, Read, Update, Delete) operations on all resources.

    CouchDB also offers a built-in administration interface accessible via Web called Fauxton.[12]

    Use cases and production deployments

    Replication and synchronization capabilities of CouchDB make it ideal for using it in mobile devices, where network connection is not guaranteed, and 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.[13]

    Users

    Users of CouchDB include:

    Data manipulation: documents and views

    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 like MapReduce.

    Views are generally stored in the database and their indexes are updated continuously. CouchDB supports a view system using external socket servers and a JSON-based protocol.[25] 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

    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 (127.0.0.1) on port 5984.

    Action Request Response
    Accessing server informationcurl http://127.0.0.1:5984/
    Creating a database named wikicurl -X PUT http://127.0.0.1:5984/wiki
    Attempting to create a second database named wikicurl -X PUT http://127.0.0.1:5984/wiki
    Retrieve information about the wiki databasecurl http://127.0.0.1:5984/wiki
    Delete the database wikicurl -X DELETE http://127.0.0.1:5984/wiki
    Create a document, asking CouchDB to supply a document idcurl -X POST -H "Content-Type: application/json" --data \'' \http://127.0.0.1:5984/wiki
    get a list of databasescurl http://127.0.0.1:5984/_all_dbs["_replicator","_users","wiki"]

    Open source components

    CouchDB includes a number of other open source projects as part of its default package.

    ComponentDescriptionLicense
    ErlangErlang is a general-purpose concurrent programming language and runtime system. The sequential subset of Erlang is a functional language with strict evaluation, single assignment, and dynamic typingApache 2.0 (Release 18.0 and later)
    Erlang Public License (Earlier releases)
    ICUInternational Components for Unicode (ICU) is an open-source project of mature C/C++ and Java libraries for Unicode support, software internationalization and software globalizationUnicode License
    jQueryjQuery is a lightweight cross-browser JavaScript library that emphasizes interaction between JavaScript and HTMLMIT License
    OpenSSLOpenSSL is an open-source implementation of the SSL and TLS protocols. The core library (written in the C programming language) implements the basic cryptographic functions and provides various utility functionsApache 1.0 and the four-clause BSD License
    SpiderMonkeySpiderMonkey is a performant JavaScript engine maintained by the Mozilla Foundation. It contains an interpreter, a JIT compiler and a garbage collectorMPL 2.0

    See also

    External links

    Notes and References

    1. Web site: Apache CouchDB. Apache Software Foundation. 15 April 2012.
    2. Web site: Smith. Jason. What is the CouchDB replication protocol? Is it like Git?. StackOverflow. Stack Exchange. 14 April 2012.
    3. Web site: Exploring CouchDB . Developer Works . IBM . March 31, 2009 . September 30, 2016 .
    4. http://mail-archives.apache.org/mod_mbox/incubator-general/200802.mbox/%3c3d4032300802121136p361b52ceyfc0f3b0ad81a1793@mail.gmail.com%3e Apache mailing list announcement
    5. http://mail-archives.apache.org/mod_mbox/incubator-couchdb-dev/200811.mbox/%3c3F352A54-5FC8-4CB0-8A6B-7D3446F07462@jaguNET.com%3e Re: Proposed Resolution: Establish CouchDB TLP
    6. https://www.pcworld.com/article/201046/couchdb_nosql_database_ready_for_production_use.html "CouchDB NoSQL Database Ready for Production Use"
    7. Web site: Katz. Damien. The future of CouchDB. 15 April 2012.
    8. Web site: Slater. Noah. Welcome BigCouch. 25 July 2013 . 25 July 2013.
    9. Web site: '2.0'. 20 September 2016. 13 January 2017.
    10. Web site: 1.8. 2.0.x Branch — Apache CouchDB® 3.3 Documentation . 2024-08-04 . docs.couchdb.org.
    11. http://couchdb.apache.org/docs/overview.html CouchDB, Technical Overview
    12. Web site: couchdb-fauxton. GitHub. apache. 2 May 2023.
    13. http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis Cassandra vs MongoDB vs CouchDB vs Redis vs Riak vs HBase comparison
    14. Web site: 2010-08-26 . Why Large Hadron Collider Scientists are Using CouchDB . 2022-03-29 . ReadWrite . en-US.
    15. Web site: Database-Deep-Dives-CouchDB . 2022-03-29 . www.ibm.com . 19 July 2019 . en-us.
    16. Web site: Database-Deep-Dives-CouchDB . 2022-03-29 . www.ibm.com . 19 July 2019 . en-us.
    17. Web site: United Airlines Streamlines Operations With Couchbase Case Study . 2022-03-29 . www.couchbase.com.
    18. http://wiki.apache.org/couchdb/CouchDB_in_the_wild "CouchDB in the wild"
    19. Web site: Meebo Gets The Classic Google Acq-hire Treatment: Most Products To Shut Down Soon . Kim-Mai . Cutler . 9 June 2012. 7 January 2016. TechCrunch. AOL Inc..
    20. Web site: npm-registry-couchapp. GitHub. npm. 17 June 2015. 7 January 2016.
    21. http://www.erlang-factory.com/conference/London2009/speakers/endafarrell CouchDB at the BBC as a fault tolerant, scalable, multi-data center key-value store
    22. http://mail-archives.apache.org/mod_mbox/couchdb-dev/200910.mbox/%3C4AD53996.3090104@canonical.com%3E Email from Elliot Murphy (Canonical)
    23. http://linux.slashdot.org/story/11/11/22/171228/canonical-drops-couchdb-from-ubuntu-one Canonical Drops CouchDB From Ubuntu One (Slashdot)
    24. Web site: Protogrid - Über uns.
    25. http://wiki.apache.org/couchdb/ViewServer View Server Documentation