Interview :: CouchDB
CouchDB uses Erlang binary internally. So, data come to CouchDB is always UTF-8 encoded. There is no problem occurred.
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.
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
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.
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.
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.
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.