Wednesday, May 11, 2011

Couch DB for a MySQL User


At last I found some time to play around with Couch DB. The installation was pretty simple and while working what was striking me was that it was too simple to be true. Just like the guy in the logo of couch DB where a  guy is seated on the sofa full relaxed I was feeling the same :D.Here I have listed a brief comparison with MySQL.

Feature
MySQL
Couch DB
Type of SQL
SQL
No SQL
Which means schema definitions are not needed and querying is free of SQL
Type of database
RDBMS
Document  database
Installation
Depends on the distribution.
Usually straight forward, unless it’s a tar distribution where you need to go through certain steps
I installed on Ubuntu, was straight forward using apt-get.
Server starts up when the OS is booted as per the default configuration.
Administration
Plenty of client applications available. Mysql administrator, Mysql work bench etc.
mysql client is a command line based client.
Futon , a simple built in web tool available to manage the database and execute the views.
Or CURL utility can be used to generate the HTTP requests.
Queries
Usual SQL based queries, where group by, sort and filtering are supported
Using map and reduction functions you can write sorts, sum, average, etc . This is fun and specially who had done programming with Erlang will enjoy this.
Find below a screen shot of a map reduce function.
Security
Support for SSL available
MySQL has permission tables where the permissions are stored and managed
No SSL availability as of now
I guess security is the biggest weakness. It’s still in primitive stage. Apparently there will be some new development.
As of now, the user name password for admin should be defined in the configuration and access control need to be implemented by the application developer.
Replication
Theoretically two way replication supported, but usually not used in production systems.
Usual replication is asynchronous and it’s based on  binary logs(where changes are recorded).
Replication can be triggered from the futon UI it self. It supports two way replication and handles conflict resolution internally, these conflicts are recorded for future references. But the issue is the replication is almost like a snapshot being replicated when triggered and not a continues process by itself. To make it continuous a cron job should be set up to periodically sync the databases or write a script which will be invoked when document updates are made.
Finding server statistics
Show status on mysql command line
http://127.0.0.1:5984/_stats  in futon can be used to retrieve the server statistics
Usual architecture
Application will have  a connector to connect to the database. Applications front end will have the java scripts to render on the client.
Client(java script) -> application server -> database server
Here the calling of the database design views can be directly done by the Client(java script ) making it simple light weight and straight forward.

An example of an aggregate function written with map reduce function is show in the image below. The equivalent SQL query will be select name, average(marks) from employee;

 read my earlier post on Mongo DB for MySQL users by visiting balagowri

No comments:

Post a Comment