Apache CouchDB

Last updated
Apache CouchDB
Original author(s) 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(s) Apache Software Foundation
Initial release2005;19 years ago (2005)
Stable release
3.3.3 [1]   OOjs UI icon edit-ltr-progressive.svg / 4 December 2023;40 days ago (4 December 2023)
Repository
Written in Erlang, JavaScript, C, C++
Operating system Cross-platform
Type Document-oriented database
License Apache License 2.0
Website couchdb.apache.org   OOjs UI icon edit-ltr-progressive.svg

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

Contents

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. [2]

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. [3]

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. [4] 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. [5] A few months after, it graduated to a top-level project. [6] This led to the first stable version being released in July 2010. [7]

In early 2012, Katz left the project to focus on Couchbase Server. [8]

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. [9] The BigCouch clustering framework is included in the current release of Apache CouchDB. [10]

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.

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. [26] 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.

ActionRequestResponse
Accessing server information
curlhttp://127.0.0.1:5984/ 
{"couchdb":"Welcome","version":"1.1.0"}
Creating a database named wiki
curl-XPUThttp://127.0.0.1:5984/wiki 
{"ok":true}
Attempting to create a second database named wiki
curl-XPUThttp://127.0.0.1:5984/wiki 
{"error":"file_exists","reason":"The database could not be created, the file already exists."}
Retrieve information about the wiki database
curlhttp://127.0.0.1:5984/wiki 
{"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-XDELETEhttp://127.0.0.1:5984/wiki 
{"ok":true}
Create a document, asking CouchDB to supply a document id
curl-XPOST-H"Content-Type: application/json"--data\'{ "text" : "Wikipedia on CouchDB", "rating": 5 }'\ http://127.0.0.1:5984/wiki 
{"ok":true,"id":"123BAC","rev":"946B7D1C"}
get a list of databases
curlhttp://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
Erlang Erlang 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 typing Apache 2.0 (Release 18.0 and later)
Erlang Public License (Earlier releases)
ICU International Components for Unicode (ICU) is an open-source project of mature C/C++ and Java libraries for Unicode support, software internationalization and software globalization Unicode License
jQuery jQuery is a lightweight cross-browser JavaScript library that emphasizes interaction between JavaScript and HTML MIT License
OpenSSL OpenSSL 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 functions Apache 1.0 and the four-clause BSD License
SpiderMonkey SpiderMonkey is a performant JavaScript engine maintained by the Mozilla Foundation. It contains an interpreter, a JIT compiler and a garbage collector MPL 2.0

See also

Related Research Articles

eXist-db is an open source software project for NoSQL databases built on XML technology. It is classified as both a NoSQL document-oriented database system and a native XML database. Unlike most relational database management systems (RDBMS) and NoSQL databases, eXist-db provides XQuery and XSLT as its query and application programming languages.

In computing, a solution stack or software stack is a set of software subsystems or components needed to create a complete platform such that no additional software is needed to support applications. Applications are said to "run on" or "run on top of" the resulting platform.

Multi-master replication is a method of database replication which allows data to be stored by a group of computers, and updated by any member of the group. All members are responsive to client data queries. The multi-master replication system is responsible for propagating the data modifications made by each member to the rest of the group and resolving any conflicts that might arise between concurrent changes made by different members.

<span class="mw-page-title-main">LAMP (software bundle)</span> Acronym for a common web hosting solution

LAMP is an acronym denoting one of the most common software stacks for the web's most popular applications. Its generic software stack model has largely interchangeable components.

In computing, a materialized view is a database object that contains the results of a query. For example, it may be a local copy of data located remotely, or may be a subset of the rows and/or columns of a table or join result, or may be a summary using an aggregate function.

Apache Hadoop is a collection of open-source software utilities that facilitates using a network of many computers to solve problems involving massive amounts of data and computation. It provides a software framework for distributed storage and processing of big data using the MapReduce programming model. Hadoop was originally designed for computer clusters built from commodity hardware, which is still the common use. It has since also found use on clusters of higher-end hardware. All the modules in Hadoop are designed with a fundamental assumption that hardware failures are common occurrences and should be automatically handled by the framework.

<span class="mw-page-title-main">Mnesia</span>

Mnesia is a distributed, soft real-time database management system written in the Erlang programming language. It is distributed as part of the Open Telecom Platform.

A document-oriented database, or document store, is a computer program and data storage system designed for storing, retrieving and managing document-oriented information, also known as semi-structured data.

An embedded database system is a database management system (DBMS) which is tightly integrated with an application software; it is embedded in the application. It is a broad technology category that includes:

<span class="mw-page-title-main">Apache Cassandra</span> Free and open-source database management system

Cassandra is a free and open-source, distributed, wide-column store, NoSQL database management system designed to handle large amounts of data across many commodity servers, providing high availability with no single point of failure. Cassandra offers support for clusters spanning multiple datacenters, with asynchronous masterless replication allowing low latency operations for all clients. Cassandra was designed to implement a combination of Amazon's Dynamo distributed storage and replication techniques combined with Google's Bigtable data and storage engine model.

A database shard, or simply a shard, is a horizontal partition of data in a database or search engine. Each shard is held on a separate database server instance, to spread load.

<span class="mw-page-title-main">LYME (software bundle)</span>

LYME and LYCE are software stacks composed entirely of free and open-source software to build high-availability heavy duty dynamic web pages. The stacks are composed of:

Semi-structured data is a form of structured data that does not obey the tabular structure of data models associated with relational databases or other forms of data tables, but nonetheless contains tags or other markers to separate semantic elements and enforce hierarchies of records and fields within the data. Therefore, it is also known as self-describing structure.

<span class="mw-page-title-main">Couchbase Server</span> Open-source NoSQL database

Couchbase Server, originally known as Membase, is a source-available, distributed multi-model NoSQL document-oriented database software package optimized for interactive applications. These applications may serve many concurrent users by creating, storing, retrieving, aggregating, manipulating and presenting data. In support of these kinds of application needs, Couchbase Server is designed to provide easy-to-scale key-value, or JSON document access, with low latency and high sustainability throughput. It is designed to be clustered from a single machine to very large-scale deployments spanning many machines.

Cloudant is an IBM software product, which is primarily delivered as a cloud-based service. Cloudant is a non-relational, distributed database service of the same name. Cloudant is based on the Apache-backed CouchDB project and the open source BigCouch project.

<span class="mw-page-title-main">Apache Drill</span> Open-source software framework

Apache Drill is an open-source software framework that supports data-intensive distributed applications for interactive analysis of large-scale datasets. Built chiefly by contributions from developers from MapR, Drill is inspired by Google's Dremel system. Drill is an Apache top-level project. Tom Shiran is the founder of the Apache Drill Project. It was designated an Apache Software Foundation top-level project in December 2016.

<span class="mw-page-title-main">MEAN (solution stack)</span> JavaScript software stack

MEAN is a source-available JavaScript software stack for building dynamic web sites and web applications. A variation known as MERN replaces Angular with React.js front-end, and another named MEVN use Vue.js as front-end.

Elliptics is a distributed key–value data storage with open source code. By default it is a classic distributed hash table (DHT) with multiple replicas put in different groups. Elliptics was created to meet requirements of multi-datacenter and physically distributed storage locations when storing huge amount of medium and large files.

<span class="mw-page-title-main">Hoodie (software)</span>

In computing, Hoodie is an open-source JavaScript package, that enables offline-first, front-end web development by providing a complete backend infrastructure. It aims to allow developers to rapidly develop web applications using only front-end code by providing a backend based on Node.js and Apache CouchDB. It runs on many Unix-like systems as well as on Microsoft Windows.

References

  1. "Release 3.3.3". 4 December 2023. Retrieved 19 December 2023.
  2. Apache Software Foundation. "Apache CouchDB" . Retrieved 15 April 2012.
  3. Smith, Jason. "What is the CouchDB replication protocol? Is it like Git?". StackOverflow. Stack Exchange. Retrieved 14 April 2012.
  4. "Exploring CouchDB". Developer Works. IBM. March 31, 2009. Retrieved September 30, 2016.
  5. Apache mailing list announcement on mail-archives.apache.org
  6. Re: Proposed Resolution: Establish CouchDB TLP on mail-archives.apache.org
  7. "CouchDB NoSQL Database Ready for Production Use" Archived 2010-11-15 at the Wayback Machine , article from PC World of July 2010
  8. Katz, Damien. "The future of CouchDB" . Retrieved 15 April 2012.
  9. Slater, Noah (25 July 2013). "Welcome BigCouch" . Retrieved 25 July 2013.
  10. "'2.0'". 20 September 2016. Retrieved 13 January 2017.
  11. CouchDB, Technical Overview Archived October 20, 2011, at the Wayback Machine
  12. "couchdb-fauxton". GitHub. apache. Retrieved 2 May 2023.
  13. Cassandra vs MongoDB vs CouchDB vs Redis vs Riak vs HBase comparison from Kristóf Kovács
  14. "Why Large Hadron Collider Scientists are Using CouchDB". ReadWrite. 2010-08-26. Retrieved 2022-03-29.
  15. iDAT, Red Cross Code, 2021-07-31, retrieved 2022-03-29
  16. "Database-Deep-Dives-CouchDB". www.ibm.com. 19 July 2019. Retrieved 2022-03-29.
  17. "Database-Deep-Dives-CouchDB". www.ibm.com. 19 July 2019. Retrieved 2022-03-29.
  18. "United Airlines Streamlines Operations With Couchbase | Case Study". www.couchbase.com. Retrieved 2022-03-29.
  19. "CouchDB in the wild" Archived 2017-07-20 at the Wayback Machine article of the product's Web, a list of software projects and websites using CouchDB
  20. Cutler, Kim-Mai (9 June 2012). "Meebo Gets The Classic Google Acq-hire Treatment: Most Products To Shut Down Soon". TechCrunch. AOL Inc. Retrieved 7 January 2016.
  21. "npm-registry-couchapp". GitHub. npm. 17 June 2015. Retrieved 7 January 2016.
  22. CouchDB at the BBC as a fault tolerant, scalable, multi-data center key-value store
  23. Email from Elliot Murphy (Canonical) Archived 2011-05-05 at the Wayback Machine to the CouchDB-Devel list
  24. Canonical Drops CouchDB From Ubuntu One (Slashdot)
  25. "Protogrid - Über uns".
  26. View Server Documentation Archived 2008-10-20 at the Wayback Machine on wiki.apache.org

Bibliography