Google News
logo
CouchDB Interview Questions
CouchDB is a database that completely embraces the web. Store your data with JSON documents. Access your documents and query your indexes with your web browser, via HTTP. Index, combine, and transform your documents with JavaScript. CouchDB works well with modern web and mobile apps. You can even serve web apps directly out of CouchDB. And you can distribute your data, or your apps, efficiently using CouchDB’s incremental replication. CouchDB supports master-master setups with automatic conflict detection.
 
CouchDB comes with a suite of features, such as on-the-fly document transformation and real-time change notifications, that makes web app development a breeze. It even comes with an easy to use web administration console. You guessed it, served up directly out of CouchDB! We care a lot about distributed scaling. CouchDB is highly available and partition tolerant, but is also eventually consistent. And we care a lot about your data. CouchDB has a fault-tolerant storage engine that puts the safety of your data first.
CouchDB is written in C++ but was replaced by 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).
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.
* JSON Documents : CouchDB stores data in JSON document.

*
RESTful Interface : CouchDB does all tasks like replication, data insertion, etc. via HTTP.

*
N-Master Replication : CouchDB facilitates you to make use of an unlimited amount of 'masters,' making for some very interesting replication topologies.

*
Built for Offline : CouchDB can replicate to devices (like Android phones) that can go offline and handle data sync for you when the device is back online.

*
Replication Filters : CouchDB facilitates you to filter precisely the data you wish to replicate to different nodes.

*
ACID semantics : The CouchDB file layout follows all the features of ACID properties. Once the data is entered into the disc, it will not be overwritten. Document updates (add, edit, delete) follow Atomicity, i.e., they will be saved completely or not saved at all. The database will not have any partially saved or edited documents. Almost all of these update are serialized, and any number of clients can read a document without waiting and without being interrupted.

*
Document storage : CouchDB is a NoSQL database which follows document storage. Documents are the primary unit of data where each field is uniquely named and contains values of various data types such as text, number, Boolean, lists, etc. Documents don't have a set limit to text size or element count.

*
Eventually consistency : CouchDB guarantees to provide availability and partition tolerance.
Authentication and Session Support: CouchDB facilitates you to keep authentication open via a session cookie like a web application.

*
Security : CouchDB also provides database-level security. The permissions per database are separated into readers and admin. Readers can both read and write to the database.

*
Validation : You can validate the inserted data into the database by combining with authentication to ensure the creator of the document is the one who is logged in.
Map/Reduce List and Show: The main reason behind the popularity of MongoDB and CouchDB is map/reduce system.
The similarity between MongoDB and CouchDB are :
 
* MongoDB and CouchDB both are the document-oriented databases.

*
MongoDB and CouchDB both are the best examples of an open-source NoSQL database. i.e., both are Schema-free.

*
MongoDB and CouchDB both support JavaScript, can be used in queries, support aggregation functions such as MapReduce and sent the database to execute it.

*
MongoDB and CouchDB both support common programming languages C, C#, Erlang, Java, JavaScript, Ruby, Python, Haskell, PHP, Perl, Smalltalk, etc.

*
These are some common functionality of CouchDB and MongoDB.
PouchDB is also a CouchDB client, and you should be able to switch between a local database or an online CouchDB instance without changing any of your application’s code.

However, there are some minor differences to note :

* View Collation :
CouchDB uses ICU to order keys in a view query; in PouchDB they are ASCII ordered.

* View Offset :
CouchDB returns an offset property in the view results. In PouchDB, offset just mirrors the skip parameter rather than returning a true offset.
The main consequences of IBM’s involvement are :
* The code is now being apache licensed, instead of GPL.
* Damien is going to be contributing much more time!
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 :
 
* Couchdbkit requires python 2.x superior to 2.6
* To install Couchdbkit using pip you must make sure that you have a recent version on distribute installed.
* $ curl -0 http://python-distribute.org/distribute_setup.py
* $ curl sudo python distribute_setup.py
* $ easy_install pip

To install or upgrade to a latest released version of couchdbkit
 
$ pip install couchdbkit
There are many reasons behind CouchDB not using Mnesia :
 
* It provides a storage limitation of 2 gigs per file.
* It requires validation and fixup cycle after a crash or power failure, so even if the size limitation is lifted, the fixup time on large files is prohibitive.
* Mnesia has some useful features, but features of Mnesia aren't really useful for CouchDB.
* Mnesia is not a general-purpose, large-scale database. It works best as a configuration type database.
* Mnesia works best as a configuration type database. It is necessary for the normal operations. The type where the data is not central to the function of the application, but necessary for normal operation of it.
* Things that need to update, configure and often reconfigure like a network router, HTTP proxies, etc. whose configuration data is rarely huge.
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.
 
* CouchDB has an HTTP-based REST API, which makes communication with the database very easy.
* CouchDB has the simple structure of HTTP resources and methods (GET, PUT, and DELETE) that are easy to understand and use.
* In CouchDB, data is stored in the flexible document-based structure so, there is no need to worry about the structure of the data.
* CouchDB facilitates users with powerful data mapping, which allows querying, combining, and filtering the information.
* CouchDB provides easy-to-use replication, using which you can copy, share, and synchronize the data between databases and machines.
No. Views are always read-only for databases and their documents.
 
Views are used for the following purpose :
 
* It filters the document from the database to find relevant data for a particular process.
* Extracting data from documents and present it in a specific order.
* Building indexes to find the document by any value or structure that resides in them and use these indexes to represent the relationship between documents.
* Finally, with views, you can make all sorts of calculations on the data in your documents

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.
Most POSIX systems are supported like GNU/Linux and OS X. Window is not officially supported but it should work.
There are certain needs that the Couchbase server can easily fulfill. The first is assuring a unified programming Interface can handle queries and searches. In addition to this, mobile and Internet of Things demands can easily be fulfilled through this. Also, various tasks like core database engine, analytics, SQL integrations, scale-out architecture, core database engine, as well as memory first architecture can easily be fulfilled. 
There are certain abilities of the same which is very useful when it comes to managing the data of the applications. In addition to this, it is also good enough to be trusted for the document applications. The users can easily deploy its architecture anywhere they want. Other capabilities include caching of data, data persistence, as well as database management. 
Couchbase Server is a fast, seamless, NoSQL database which was initially termed as Membase. It is a software package that is technologically advanced multi-model NoSQL, and is file-oriented. It has been proposed for interacting through web applications.
The answer to this question is yes, Couchbase is a distributed multiform NoSQL file-oriented database software package. Couchbase is generally defined as open-source software that was released under Apache license that consisted of a community and enterprise edition.
MongoDB provides multi-step scalability, whereas, Couchbase offers a seamless scalability property. The reason why Couchbase is more advanced than MongoDB is due to the consistency. Couchbase arrives with a high consistency power; while on the contrary, MongoDB offers a low consistency power. Plus, Couchbase’s uptime is always up. While on the other hand, MongoDB’s uptime needs a bit of maintenance.
Couchbase is capable enough of storing key-values as well as credentials. Thus, it can store data like binary data, JSON documents, and many more.Couchbase server makes use of a binary Memcached protocol to perform the high-end functionalities as well as REST API’s SQL in order to view the queries.
 
Apache CouchDB, on the contrary, is capable of storing JSON documents. It also provides facilities to attach non-JSON files to the JSON documents.
The port numbers which have been configured are Port 11210 and Port 11211. The explanations have been mentioned right below.
 
* Firstly, Port 11210 happens to be a port that is openly accessible to the clients implementing a version of 2.0 of memcapable API. These are the ‘vBucket aware’ client. They are depending and hashing algorithm to the map keys to an appropriate ‘vBuckets’ number. Later on, the vBuckets are mapped to the respective server and thereby provides a coating of indirection that enables the rebalancing of the vibrant cluster. Also, it offers replication, failover, as well as group expansion or contraction.

* Secondly, Port 11211 happens to be the Memcached port number which processes the request from the clients guiding 1.0 version of API requirement. These clients depend on the consistent algorithm to the map keys in order to serve a catalog for length server.
In Couchbase, a document usually refers to an entry in the database. A document consists of an ID that happens to be unique by nature. Its value contains the real application data. Documents are stored on the server as JSON. While JSON is a structured format that happens to be a structured format, it can be searched and accordingly get queried by following the below-mentioned command.

Syntax : 
{
“type”: “product”,
“sku”: “CBSRV45DP”,
“msrp”: [5.49, “USD”],
“ctime”: “092011”,
“mfg”: “couchbase”,
“tags”: [“server”, “database”, “couchbase”, “nosql”, “fast”, “json”, “awesome”]
}
N1QL happens to be a query language or the non-first usual form of the query language. It is purposed to manipulate JSON data in the Couchbase server. Some of its statements to operate the JSON data are as follows:
 
* INSERT
* DELETE
* UPDATE
* MERGE
* SELECT
In Couchbase, Data structures are similar to those included in javascript.Map is a key-value structure that is similar to a JavaScript Object. In Map, a value is accessed by employing the key string. One can place the values in the very beginning or at the end.
Couchbase Server comprises an object-managed, built-in, and multi-threaded cache. The cache is capable of implementing APIs that are memcached compatible, for example, append, prepend, set, get, and more.
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.
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.
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 :
POST /_replicate with a post body of </li>    
{"source":"$source_database"   
,   
"target":"$target_database"}  
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.
PouchDB itself does not provide built-in encryption features, but it can be used in conjunction with encryption libraries or techniques to enhance security. Here's how PouchDB can handle encryption and security:

Client-Side Encryption :
* Developers can implement client-side encryption using encryption libraries such as CryptoJS or Stanford JavaScript Crypto Library (SJCL) to encrypt data before storing it in PouchDB.
* By encrypting data on the client-side before storing it in the database, developers can ensure that sensitive information remains encrypted while at rest, protecting it from unauthorized access even if the underlying storage mechanism is compromised.

HTTPS Communication :
* When using PouchDB in a web application, developers should ensure that communication between the client and server databases is encrypted using HTTPS (HTTP over TLS).
* HTTPS encrypts data in transit, preventing eavesdropping and tampering by attackers. It ensures that data transmitted between the client and server databases remains confidential and secure.

Server-Side Security :
* Developers should also implement security measures on the server-side, such as authentication, authorization, and access control, to protect data stored in the server database.
* Server-side security measures help control access to the database, authenticate users, and enforce permissions to prevent unauthorized access or tampering with data.

Third-Party Plugins :
* Developers can use third-party plugins or libraries that provide encryption and security features specifically designed for use with PouchDB.
* For example, the crypto-pouch plugin provides client-side encryption for PouchDB using the Stanford JavaScript Crypto Library (SJCL), allowing developers to encrypt data before storing it in the database.

Security Best Practices :
* Developers should follow security best practices when using PouchDB, such as validating user input, sanitizing data, and implementing proper error handling to prevent security vulnerabilities such as injection attacks or data leakage.
* By adhering to security best practices, developers can mitigate security risks and ensure that their applications remain secure and resilient against potential threats.
PouchDB plugins extend the functionality of the core PouchDB library by providing additional features, integrations, or customizations. These plugins can be developed by the PouchDB community or by individual developers and can serve various roles within PouchDB-based applications. Here's an overview of the role of PouchDB plugins:

Extending Functionality : PouchDB plugins allow developers to extend the functionality of the core PouchDB library by adding new features or capabilities. For example, plugins can provide support for encryption, full-text search, geospatial queries, or real-time synchronization with external databases.

Integrations : PouchDB plugins enable integration with external services, libraries, or frameworks, allowing developers to leverage existing tools and infrastructure within their PouchDB-based applications. For example, plugins can provide integration with authentication providers, data visualization libraries, or offline-first frameworks.

Customizations : PouchDB plugins allow developers to customize and tailor PouchDB to meet the specific requirements of their applications. Developers can create plugins to implement custom storage backends, conflict resolution strategies, replication protocols, or data transformation logic.

Performance Optimization : PouchDB plugins can optimize performance by providing alternative storage backends, indexing mechanisms, or caching strategies. Plugins can help improve the speed and efficiency of database operations, especially in large-scale or performance-critical applications.

Cross-Platform Support : PouchDB plugins enable cross-platform support by providing compatibility with different environments, browsers, or runtime environments. Plugins can provide polyfills, shims, or adapters to ensure consistent behavior and functionality across diverse platforms and devices.

Community Contributions : PouchDB plugins are often developed and maintained by the PouchDB community, allowing developers to contribute new features, bug fixes, or improvements to the ecosystem. Plugins foster collaboration and innovation within the community, driving the evolution and growth of the PouchDB ecosystem.