CouchDB Interview Questions1) What is CouchDB?CouchDB is documented database server accessible through a RESTful JSON API. It is distributed, robust, incremental replication with bi-direction. It is schema-free with flat address space. CouchDB is an open source NoSQL database which focuses on ease of use. It was developed by Apache. It is fully compatible with the web. CouchDB uses JSON to store data, JavaScript as its query language to transform the documents, using MapReduce, and HTTP for an API. CouchDB features are as follows:
Latest release: Version 2.2.0 on Aug 8, 2018 2) In which language CouchDB is written?CouchDB is written in Erlang. It is a concurrent, functional programming language mainly focuses on fault tolerance (Erlang programming language also used for build massively scalable soft real-time system with requirements on high availability). Some of its parts are written in C language too. As we know that CouchDB supports view server and the views (form map or reduce) are written in JavaScript per default (but can also be written in Erlang). Therefore CouchDB requires the JavaScript engine SpiderMonkey (which is written in C language). 3) In which language CouchDB's early work was started?CouchDB early work was started in C++. But later, it was replaced by Erlang OTP platform. Erlang has proven as an excellent match for this project. 4) How CouchDB is different from other SQL databases?CouchDB is not a relational database. Some people think that it is a replacement for a relational database, but it is completely different from SQL databases. It is fast, efficient and faults tolerant.
Structure of NoSQL database: 5) Is CouchDB used in the Software industry?CouchDB is very popular now a day, and many companies are using CouchDB. These are the essential features of CouchDB:
That's why the software companies use CouchDB. Here we have a list of Top companies which uses CouchDB:
6) What is the difference between CouchDB and MongoDB?These are the following differences:
MongoDB is faster than CouchDB, and scalability is also better of the MongoDB. CouchDB runs on different operating system like Android, iOS platform but MongoDB doesn't support mobile OS. Mongo DB is better as compare to CouchDB for rapid growth when the structure is not clearly defined from the beginning. 7) What is the similarity between MongoDB and CouchDB?The similarity between MongoDB and CouchDB are:
These are some common functionality of CouchDB and MongoDB. 8) What are the main features of CouchDB?
9) Why Does CouchDB not use Mnesia?There are many reasons behind CouchDB not using Mnesia:
10) How would you use transactions with CouchDB?CouchDB uses an "Optimistic concurrency" model. In this model, if you send a document version along with your update, CouchDB rejects the change if the current document version doesn't match to your sent update. So, you have to re-frame many normal transaction based scenarios for CouchDB. It's helpful to approach problems from a higher level, rather than attempting to mold Couch to a SQL based world. If you have a document describing the item, and it includes a field for "Quantity available", you can handle concurrency issues: First of all recover document, note down property that sent by CouchDB along with database, after that, Decrement the quantity field, if it's greater than zero. After that, send the updated document back using the _rev property. Check, If the _rev matches the currently stored number, be done else if there is a conflict when _rev is not matched then recover the newest document version. For example: I would like to take a ("master product") document that contains all the data information like name, picture description, price, etc. Here we have to create to a field (product-key and, Claimed-by) by adding a new document inventory-ticket, if you are spelling a model of a hammer and have 20 items to sell, you might have documents with keys like hammer-1, hammer-2 to represent each one individually. Now, I would like to create a view that gives a list of available hammerThis gives me list of available tickets with their product_key, I could grab a group of these when someone wants to buy hammer then iterate through the sending updates until I successfully claim one. Reduce This gives me a list of total unclaimed inventory_ticket items. This example represents that transaction with CouchDB is possible that it substantially reduces conflicting updates, and cut down on the needs to respond to a conflict with the new updates. In this model, you won't have multiple users attempting to change data in primary product entry. When you have multiple users for a single ticket, then you have to identify those users who want to retake it by your view, ignore those, and you move to the next ticket and try again. 11) As CouchDB is written in Erlang and Erlang is known as slow to adopt Unicode. So, if it creates a problem for CouchDB?CouchDB uses Erlang binary internally. So, data come to CouchDB is always UTF-8 encoded. There is no problem occurred. 12) What is the usage of CouchDB?CouchDB facilitates developers to write a client-side application which interacts directly to the Couch without the need of server-side middle layer. It reduces the time of development and handling replication. Its database is stored locally so the application can run almost no latency. The main objective of CouchDB is to run on the internet applications and the connected devices through which we access the internet.
13) What do you know about couchdbKit?The couchdbKit provides a framework for your Python application to access and manage Python applications. It offers features to easily access and manage CouchDB by a client, allow to manage databases, Couch database server, doc management, and view access. Objects mostly reflect python object for service. Server and data objects could be used for example. Steps to install couchdbkit:
To install or upgrade to a latest released version of couchdbkit $ pip install couchdbkit 14) Can Views update documents or databases?No. Views are always read-only for databases and their documents. Views are used for the following purpose:
For example: If documents represent your company's financial transactions, a view can answer the question of what the spending was in the last week, month, or year. 15) What platforms are supported in CouchDB?Most POSIX systems are supported like GNU/Linux and OS X. Window is not officially supported but it should work. 16) What is the use of sequences? How do you do sequences?Sequences are often used to ensure unique identifiers for each row in a database table. Sequences are hard to realize with replication. CouchDB generates unique ids from its own, and you can specify your own as well, so you don't need a sequence here. If you use a sequence for something else, you might find a way to express in CouchDB in another way. 17) How can you do replication?Replication: Replication synchronizes two copies of the same database; these databases live on the same server or can be live on two different servers. If you change one copy of the database, replication will send the details to another copy. For replication, first you have to send request of HTTP to CouchDB with a source, and a target database and CouchDB will send the changes from source to target. Let's see, how replication looks like: Here $source_database and $target_database can be the names of local database or full URIs of remote databases. Both databases need to be created before they can be replicated from or to. 18) Is it possible to communicate to CouchDB without going through HTTP/ API?CouchDB's data model and internal API map the REST/HTTP model in a very simple way that any other API would inherit some features of HTTP. However, there is a plan to refractor CouchDB's internals to provide a documented Erlang API. |