Prev Next

Database / CouchDB Interview Questions

1. What is Apache CouchDB and what makes it different from relational databases? 2. What data model does CouchDB use and how is a document structured? 3. What is the CouchDB HTTP REST API and how do you perform basic CRUD operations? 4. What is MVCC (Multi-Version Concurrency Control) in CouchDB and how does it handle write conflicts? 5. What is the _rev field in CouchDB and why is it required for updates and deletes? 6. What is the CouchDB storage engine (B-tree) and how does its append-only write work? 7. What is database compaction in CouchDB and when should you run it? 8. What are CouchDB attachments and when would you use them? 9. What is the difference between CouchDB and Couchbase? 10. What are the CAP theorem trade-offs for CouchDB — is it CP or AP? 11. What are CouchDB design documents and what do they contain? 12. What are MapReduce views in CouchDB and how do you define a map function? 13. How does the reduce function work in CouchDB views and what are the built-in reduce functions? 14. What are view indexes in CouchDB and how are they built and updated, including stale options? 15. What is the Mango query language in CouchDB and how does it differ from MapReduce views? 16. How do you create and use a Mango index in CouchDB (json and text indexes)? 17. What are the query operators available in the Mango selector syntax? 18. What is the _all_docs endpoint in CouchDB and how does it differ from a custom view? 19. How do you paginate results in CouchDB views using startkey, endkey, and skip/limit? 20. What is a list function in CouchDB and when would you use it? 21. How does CouchDB replication work and what is the replication protocol? 22. What is the difference between one-shot and continuous replication in CouchDB? 23. What is filtered replication in CouchDB and how do you implement it? 24. What is CouchDB Cluster mode (CouchDB 2.x+) and how does it differ from single-node CouchDB 1.x? 25. How does CouchDB cluster sharding work — what are the Q, n, r, and w parameters? 26. What is the _node and _cluster_setup API used for in CouchDB clustering? 27. How does CouchDB handle replication conflicts and what strategies exist to resolve them? 28. What is the CouchDB winning revision algorithm for conflict resolution? 29. What is PouchDB and how does it enable offline-first applications with CouchDB sync? 30. What is Couchbase Sync Gateway and how does it relate to CouchDB's replication model? 31. How does CouchDB implement authentication — cookie auth, JWT, and proxy auth? 32. What is CouchDB's permission model — admin party, database admins, and database readers? 33. How do you implement document-level security in CouchDB using validate_doc_update functions? 34. What is a CouchDB _security object and how do you configure roles and members? 35. How do you enable SSL/TLS in CouchDB and what configuration is required? 36. How do you monitor CouchDB performance using the _stats and _active_tasks endpoints? 37. What are the key CouchDB configuration parameters to tune for production (max_dbs_open, os_process_limit, etc.)? 38. How does CouchDB handle large document sets — what are the performance trade-offs of large vs many small documents? 39. What is the CouchDB _changes feed and how do you use it for real-time event streaming? 40. What are CouchDB update handlers and how do they differ from direct PUT operations? 41. What are CouchDB show functions and when were they deprecated? 42. How do you back up and restore a CouchDB database? 43. How does CouchDB compare to MongoDB for document storage use cases? 44. What are common CouchDB anti-patterns and how do you avoid them? 45. How do you migrate data between CouchDB versions or instances?

1. What is Apache CouchDB and what makes it different from relational databases?

Apache CouchDB is an open-source NoSQL document database that stores all data as self-contained JSON documents and exposes its entire API over plain HTTP/HTTPS. No proprietary wire protocol or special client driver is required....

Read full answer

2. What data model does CouchDB use and how is a document structured?

CouchDB uses a document data model : all data is stored as discrete JSON objects grouped into databases. There is no enforced schema — documents in the same database can have entirely different fields....

Read full answer

3. What is the CouchDB HTTP REST API and how do you perform basic CRUD operations?

CouchDB maps every database operation to a standard HTTP method and URL. The server root is typically http://localhost:5984 ....

Read full answer

4. What is MVCC (Multi-Version Concurrency Control) in CouchDB and how does it handle write conflicts?

MVCC in CouchDB means every write produces a new immutable version of the document instead of modifying data in place. Readers always see a consistent snapshot from the moment they start reading; no read locks are acquired....

Read full answer

5. What is the _rev field in CouchDB and why is it required for updates and deletes?

The _rev field is CouchDB's revision token — a unique identifier for a specific version of a document. Its format is {generation}-{hash} where generation is a monotonically increasing integer (starting at 1) and hash is an MD5 of the document...

Read full answer

6. What is the CouchDB storage engine (B-tree) and how does its append-only write work?

CouchDB stores each database as a single file on disk structured around an append-only B-tree . There are multiple B-trees per database file: one for documents and one for each view index....

Read full answer

7. What is database compaction in CouchDB and when should you run it?

Database compaction rewrites a CouchDB database file from scratch, retaining only the current (winning) revision of each document and discarding all stale revisions and orphaned B-tree nodes. Because CouchDB uses an append-only storage engine, every update grows the file....

Read full answer

8. What are CouchDB attachments and when would you use them?

Attachments in CouchDB are binary blobs stored directly alongside a document under the reserved _attachments key. Each attachment has a filename, a MIME content type, byte length, and an MD5 digest....

Read full answer

9. What is the difference between CouchDB and Couchbase?

CouchDB and Couchbase are two distinct products. CouchDB is an Apache project....

Read full answer

10. What are the CAP theorem trade-offs for CouchDB — is it CP or AP?

CouchDB is an AP system — it prioritizes Availability and Partition tolerance over strict Consistency. When a network partition occurs, CouchDB nodes on either side continue accepting reads and writes rather than refusing requests to maintain linearizability....

Read full answer

11. What are CouchDB design documents and what do they contain?

Design documents are special CouchDB documents whose IDs begin with _design/ . They live in the same database as regular documents but hold server-side JavaScript code that CouchDB's query server executes....

Read full answer

12. What are MapReduce views in CouchDB and how do you define a map function?

MapReduce views are CouchDB's primary indexing mechanism. A view has a map phase (mandatory) and an optional reduce phase....

Read full answer

13. How does the reduce function work in CouchDB views and what are the built-in reduce functions?

The reduce function in a CouchDB MapReduce view aggregates the values emitted by the map function within a key range. CouchDB implements reduce using a rereduce mechanism: values are first reduced in small groups (reduce pass), then those partial results...

Read full answer

14. What are view indexes in CouchDB and how are they built and updated, including stale options?

A view index in CouchDB is a persistent B-tree file on disk that stores all the key-value pairs emitted by a view's map function across all documents in the database. It is stored separately from the main database file (with...

Read full answer

15. What is the Mango query language in CouchDB and how does it differ from MapReduce views?

Mango is CouchDB's declarative, MongoDB-inspired query language introduced in CouchDB 2.0. Instead of writing JavaScript map functions, you POST a JSON selector document to the _find endpoint....

Read full answer

16. How do you create and use a Mango index in CouchDB (json and text indexes)?

Mango supports two index types: json indexes (B-tree, for equality and range queries on specific fields) and text indexes (full-text Lucene-backed, for free-text search on string fields). Both are created via POST to /_index ....

Read full answer

17. What are the query operators available in the Mango selector syntax?

Mango selectors are JSON objects where each key is a document field or a Mango operator. Operators begin with $ ....

Read full answer

18. What is the _all_docs endpoint in CouchDB and how does it differ from a custom view?

The _all_docs endpoint is a built-in view that CouchDB automatically maintains for every database. It returns all non-deleted documents sorted by their _id (ascending by default)....

Read full answer

19. How do you paginate results in CouchDB views using startkey, endkey, and skip/limit?

CouchDB views are sorted B-trees, so efficient pagination uses key-based cursoring rather than offset-based skipping. Two approaches exist: offset pagination (simpler but slow at large offsets) and key-based pagination (efficient at any depth)....

Read full answer

20. What is a list function in CouchDB and when would you use it?

A list function is a server-side JavaScript function stored in a design document under the lists key. It acts as a streaming transformer for view query results — instead of returning raw JSON rows, it lets you produce any output...

Read full answer

21. How does CouchDB replication work and what is the replication protocol?

CouchDB replication is a document-level sync protocol that copies documents from a source database to a target database using standard HTTP. Either or both of source and target can be local or remote CouchDB instances....

Read full answer

22. What is the difference between one-shot and continuous replication in CouchDB?

CouchDB supports two replication modes: one-shot (the default) and continuous . The mode is set by the continuous boolean in the replication document....

Read full answer

23. What is filtered replication in CouchDB and how do you implement it?

Filtered replication allows you to replicate only a subset of documents from a source database, rather than copying every document. This reduces bandwidth, storage on the target, and replication lag....

Read full answer

24. What is CouchDB Cluster mode (CouchDB 2.x+) and how does it differ from single-node CouchDB 1.x?

CouchDB 2.0 (released 2016) absorbed the BigCouch clustering code from Cloudant and made clustered operation the default architecture. CouchDB 3.x continues this model....

Read full answer

25. How does CouchDB cluster sharding work — what are the Q, n, r, and w parameters?

In a CouchDB cluster, each database is divided into Q shards (also called range partitions). The key space of document IDs is divided into Q equally-sized ranges using consistent hashing....

Read full answer

26. What is the _node and _cluster_setup API used for in CouchDB clustering?

The _node and _cluster_setup APIs are the two primary endpoints for managing a CouchDB cluster's topology. They are distinct in scope: _node operates on individual node configuration, while _cluster_setup orchestrates the multi-step process of forming or extending a cluster....

Read full answer

27. How does CouchDB handle replication conflicts and what strategies exist to resolve them?

A replication conflict in CouchDB occurs when two nodes have independently updated the same document (same _id ) and neither update knew about the other. This is the normal result of multi-master or offline-sync workflows — it is not an...

Read full answer

28. What is the CouchDB winning revision algorithm for conflict resolution?

When CouchDB has two or more conflicting revisions of the same document, it must deterministically pick one as the winning revision — the one returned by a normal GET request without ?conflicts=true . The algorithm is deterministic so that all...

Read full answer

29. What is PouchDB and how does it enable offline-first applications with CouchDB sync?

PouchDB is an open-source JavaScript database that runs entirely inside the browser (using IndexedDB or WebSQL as the local storage backend) or in Node.js (using LevelDB). It implements the CouchDB replication protocol, which means it can sync bidirectionally with any...

Read full answer

30. What is Couchbase Sync Gateway and how does it relate to CouchDB's replication model?

Couchbase Sync Gateway is the replication middleware layer in the Couchbase mobile stack. It sits between mobile clients running Couchbase Lite (the embedded mobile database) and a Couchbase Server cluster, handling authentication, authorization, and document routing.

Read full answer

31. How does CouchDB implement authentication — cookie auth, JWT, and proxy auth?

CouchDB supports four authentication mechanisms, configurable simultaneously. Each request is checked against the enabled handlers in order....

Read full answer

32. What is CouchDB's permission model — admin party, database admins, and database readers?

CouchDB has a two-tier permission hierarchy: server-level admins and database-level members . Understanding each tier and the dangerous default state ("admin party") is essential before deploying any CouchDB instance....

Read full answer

33. How do you implement document-level security in CouchDB using validate_doc_update functions?

The validate_doc_update (VDU) function is a JavaScript function stored in a design document that CouchDB calls before every document write to that database. If the function throws an error, the write is rejected with the specified HTTP status and message....

Read full answer

34. What is a CouchDB _security object and how do you configure roles and members?

The _security object is a special document stored at /db/_security . It defines which users and roles can act as admins (write design documents, change security) or members (read and write regular documents) for that specific database....

Read full answer

35. How do you enable SSL/TLS in CouchDB and what configuration is required?

CouchDB has a built-in HTTPS listener that can be enabled by adding a [ssl] section to the CouchDB configuration ( local.ini or local.d/*.ini ). No reverse proxy is required for basic TLS, though using nginx in front is common in...

Read full answer

36. How do you monitor CouchDB performance using the _stats and _active_tasks endpoints?

CouchDB exposes two key monitoring endpoints out of the box — /_stats and /_active_tasks — which together give a real-time snapshot of server health and ongoing operations. GET /_stats returns a JSON object of cumulative performance counters organized by category....

Read full answer

37. What are the key CouchDB configuration parameters to tune for production (max_dbs_open, os_process_limit, etc.)?

CouchDB's default configuration targets a single-developer workstation. Production deployments require tuning several parameters across different configuration sections: Key CouchDB Production Configuration Parameters Section / Key Default What it controls [couchdb] max_dbs_open 500 Maximum numbe

Read full answer

38. How does CouchDB handle large document sets — what are the performance trade-offs of large vs many small documents?

CouchDB does not have a hard document size limit (the default max_document_size is 4GB), but the performance trade-offs between storing data as a small number of large documents versus many small documents are significant. Large documents (e.g., one document per...

Read full answer

39. What is the CouchDB _changes feed and how do you use it for real-time event streaming?

The _changes feed is CouchDB's built-in event stream. It reports every document change (create, update, delete) in a database as a sequence of events, each with a sequence number ( seq ), document ID ( id ), list of changed...

Read full answer

40. What are CouchDB update handlers and how do they differ from direct PUT operations?

Update handlers are server-side JavaScript functions stored in a design document under the updates key. They allow you to perform document transformations atomically on the server without a client round-trip — the client sends a POST request, and the update...

Read full answer

41. What are CouchDB show functions and when were they deprecated?

Show functions are server-side JavaScript functions stored in a design document under the shows key. They transform a single document into any output format (HTML, XML, plain text) directly from CouchDB, without requiring a separate application server....

Read full answer

42. How do you back up and restore a CouchDB database?

CouchDB does not have a dedicated backup command like mysqldump . The recommended backup approaches depend on your deployment type and RPO requirements: 1....

Read full answer

43. How does CouchDB compare to MongoDB for document storage use cases?

Both CouchDB and MongoDB are JSON document databases, but they make fundamentally different architectural choices that determine where each excels. CouchDB vs MongoDB for Document Storage Aspect CouchDB MongoDB Query interface HTTP REST — any HTTP client; Mango JSON queries...

Read full answer

44. What are common CouchDB anti-patterns and how do you avoid them?

Several CouchDB anti-patterns cause performance degradation, excessive conflicts, or runaway disk usage. Understanding them helps you design applications that work with CouchDB's architecture rather than against it.

Read full answer

45. How do you migrate data between CouchDB versions or instances?

CouchDB provides several migration paths depending on whether you are upgrading in place, moving to a new cluster, or changing data structure during migration. 1....

Read full answer

«
»

Comments & Discussions