7. First released in 2005 and later became Apache project in 2008
Relax: Non-technical person can learn it
Fault tolerant and failure occur in controlled environment
Scaling: Growing and shrinking of hardware in your application is allowed
CouchDB is written in Erlang, a functional programming language with a focus
on writing robust, fault tolerant and highly concurrent applications
A document oriented NoSQL database
Store data with JSON documents
Uses JavaScript as a query language for Map/Reduce indexes
HTTP for its API
RESTful interface
Eventual consistency
Replication
CouchDB
8. Architecture of CouchDB
It is a 2-tier architecture
CouchDB uses HTTP as its main
programming interface and JSON for
data storage.
As we have JavaScript on Client side,
performance will increase due to
compatibility of JSON with JavaScript
CouchDB is compatible to platforms
such as Windows, Linux, Mac-iOS,
Android mobiles.
CouchDB is more suitable for Client app
such as web applications.
9. It is a computer program designed for storing, retrieving, and managing
document-oriented information, also known as semi-structured data
Unlike a relational database, CouchDB 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 databases get their type information from the data itself, normally
store all related information together
It allows every instance of data to be different from any other. This makes
them more flexible in dealing with change and optional values, maps more
easily into program objects and often reduces database size. This makes them
attractive for programming modern web applications, which are subject to
continual change in place, and speed of deployment is an important issue
Document oriented database
11. JSON documents
It is Java script object notation.
It is a open standard format that uses human-readable text to transmit
data objects consisting of attribute–value pairs
It is a light weight data format based on JavaScript syntax therefore
web
application is very good client of CouchDB
It largely replaces XML
In JSON document, curly braces ({}) wrap objects, and objects are
key/value lists. Keys are strings that are wrapped in double quotes ("").
Finally, a value is a string, an integer, an object, or an array ([]). Keys
and values are separated by a colon (:), and multiple keys and values by
comma (,).
13. A MapReduce program is composed of
Map(): procedure (method) that performs filtering and sorting (such as
sorting students by first name)
Reduce() method that performs a summary operation (such as counting
the number of students, yielding name frequencies).
CouchDB uses predefined map and reduce functions in a style known
as MapReduce.
These functions provide great flexibility because they can adapt to
variations in document structure, and indexes for each document can be
computed independently and in parallel. The combination of a map and
a reduce function is called a view in CouchDB terminology.
Map/Reduce
15. HTTP is most widely deployed end-user visible protocol in existence. It handles
everything from serving, routing, proxying, monitoring, measuring and debugging.
The main way to do anything with CouchDB is via HTTP. Create a database: make
an HTTP request; create some data: make an HTTP request; query your data: make
an HTTP request; set up replication: make an HTTP request; configure the
database: make an HTTP request. You get the idea.
HTTP for API
19. Pros:
We don't need to fit our data into one of those higher-order normal forms
We can change the "schema" of our data at any time
Our data will be indexed exactly for our queries, so we will get results in constant
time.
We don’t require plugins such as Adobe Flash player or any.
Cons:
We need to create views for each and every query, i.e. ad-hoc like queries (such as
concatenating dynamic WHERE's and SORT's in an SQL),queries are not
available.
We will either have redundant data, or we will end up implementing join and sort
logic on "client-side"
Pros and Cons of CouchDB
20. PouchDB
It is the newest project on the scene. PouchDB is a pure JavaScript implementation of
CouchDB targeted at the browser. Simply called CouchDB in JavaScript for the browser.
PouchDB is the oldest idea, but it took the longest to realize because browsers weren’t
ready for it. Now is the time though that we can build and ship a CouchDB compatible
data store and replication engine that lives entirely in your browser. If you want to build
web apps that can seamlessly synchronize data between a laptop, a phone and a server
and not treat one as a “master” and the other as “slaves”, PouchDB is your solution.
TouchDB
TouchDB i-OSand Android are Objective-C and Java implementations of the same idea,
but for mobile phone platforms. They natively integrate into your iOS and Android
applications and allow synchronization between themselves, multiple devices,
Friends Of CouchDB
34. To open built-in web interface of CouchDB visit
http://127.0.0.1:5984/
If everything goes fine then it show output as
{
"couchdb":"Welcome","uuid":"4ba9012bcbbaeaead6808245e5a758fe",
"version":"1.6.1",
"vendor":{
"version":"1.6.1","name":"The Apache Software Foundation”
}
}
35. You can interact with the CouchDB web interface by using the following url
−http://127.0.0.1:5984/_utils/
This shows you the index page of Futon, which is the web interface of CouchDB
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52. Map function
function(doc) {
var Name,Department,Address;
if(doc.Name && doc.Department){
Address=doc.Address;
Department=doc.Department;
Name=doc.Name;
emit(Name, Department);
}
}