SQL Database Over CouchDB

Why Use A SQL Database Over CouchDB ::

This article is a compare and contrast of SQL database vs. CouchDB. Explains why SQL solutions will continue to be the preferred database moving forward.

CouchDB is a new database technology developed by Damien Katz and released as an Apache project in 2010.  CouchDB is an acronym that stands for a “cluster of unreliable commodity hardware” database.  The goal was to develop a database technology designed from the ground up to support database needs of the web.  During the design phase, the designer of CouchDB decided to use a non-SQL approach to store and access data. The following discussion contrasts SQL and CouchDB.

SQL Has a Long and Successful History

In making the decision to turn away from SQL, CouchDB makes the adoption path extremely difficult.  SQL has been in use since the 1974, and has undergone several revisions to adapt to changing needs and standards.  In addition, database vendors have improved database performance by taking advantage of hardware advances, improved SQL standards, and industry experience.  With nearly 40 years of success, SQL is still in use for one simple reason: it works.
When new business needs arise, database vendors seek to improve or extend SQL rather than try to replace it.  This has been the history of SQL – it evolves as needs change.  The IT industry will continue to support SQL because of its flexibility.

Getting Help With SQL

Most companies are not able to have their IT needs satisfied solely by their internal staff.  Consultants play an important role in satisfying the IT needs of many companies.  Because of the near universal use of SQL by business, SQL consulting services are widely available at a reasonable cost.  CouchDB does not have the same level of penetration in IT departments and thus does not have the same level of consulting support.  Either sufficient numbers of CouchDB consultants will not be available, or the cost of those consultants will make many projects prohibitively expensive.

Beyond the availability of SQL consulting, there are numerous books and other sources of SQL documentation and assistance.  Any bookstore that carries IT-related books will have books on SQL.  Also, a Google search of the term “SQL documentation” returns over 23,000,000 hits.  In contrast, a similar search for “CouchDB documentation” returns only 421,000 hits.

Complexity of Using CouchDB

CouchDB is a JSON (JavaScript Object Notation) document store.  According to Wikipedia, JSON is a “text-based open standard designed for human-readable data interchange.”
Because of its data model, CouchDB is good at storing documents that do not change often.  This is because CouchDB uses an append-only, single file per database approach.  CouchDB can persist data easily but frequent data updates causes the database to grow rapidly.  The database will need to be periodically compressed.

The data model is one of the CouchDB complexity issues.  The query language is another complexity issue.  Non-technical users can use SQL.  With minimal training, most people are able to use SQL to perform common database queries.  On the other hand, CouchDB uses a language similar to JavaScript, which is beyond the grasp of most non-technical users.  For example, the following code snippet will display all comments for all blog posts in a CouchDB database.

function(doc) {
for (var i in doc.comments) {
map(doc.comments[i].author, doc.comments[i].content);

While this is a simple example, it demonstrates that the skill and ability to do this kind of coding will require special technical training. In contrast, the SQL query for the same task would be “Select author, content from comments”.

Summing it Up

SQL is a refined standard that has proven its value over time.  While CouchDB may provide some improvement in certain circumstances, it does not have the support and capability that SQL databases deliver.  SQL solutions will continue to be the preferred database option for most applications.

The preceding article was written by Thomas B. and he is article writer for sqlsolutions