The NoSQL document store's new SQL query language aims to make document data useful to existing and previous-generation analytics and reporting tools
Version 4.0 of Couchbase Server, a NoSQL document store that competes with the likes of MongoDB and Cassandra, is now available. Its main mission is to make working with unstructured data (namely JSON) as easy as querying more conventional row-and-column databases.
Couchbaseย is following the success of projects like Spark to provide easy-to-program tools that obtain quick, actionable results. In Couchbaseโs eyes, SQL is still one of the best ways to accomplish the task.
I speak SQL to my document store
Couchbase Server 4.0 usesย N1QL,ย a query language that extends the SQL syntax with commands specific to JSON documents.ย JSON syntax can nest data within other data, so some of the extensions allow developers to unnest documents and treat them as if they were conventional tabular data.
The language only targets SQL โ92, so it doesnโt provide some of the latest and most powerful SQL syntax, nor does it support transactions. But other developer-oriented functions are available, such as the EXPLAIN keyword for describing how the query optimizer processes a statement. Plus, Couchbase plans to add features like transactions over time.
InfoWorldโs Ian Pointer took aย prerelease version of Couchbase 4โs N1QLย for a test-drive. Based on what he saw, Pointer claimed the view system for Couchbase,ย which is currentlyย used to extract data from the system, could in time โslowly [fade] away as N1QL becomes the standard for interacting with Couchbase documents.โย Couchbase wants N1QL to be akin to the SQL that people know and use, not merely a crippled subset of it.
Couchbase isnโt alone in providing a SQL-like query language. Cassandra has CQL, which has beenย the official query interface for the systemย since version 2.0. But N1QL provides some features not offered in Cassandra 2.0, such as JOIN operations. MongoDB also has a SQL connector, slated for the 3.2 release, designed to help interface with third-party products like Tableau โ but it too lacks the ability to perform JOINs.ย
Old school vs. new school
If the transformative power of big data tools is best unleashed through programmatic interfaces โ for example, Couchbaseโs view and map/reduce jobs โ why are envelope-pushing products like Couchbase, Cassandra, and MongoDB adding old-school SQL interfaces? (The irony of โSQL on NoSQLโ is hard to ignore.)
One obvious reason is to connect their products to legacy BI tools that use SQL for querying. But another reason, according to Couchbase, is that despite its limitations, SQL allows for rapid application development since a good deal can be accomplished in a query with relatively little code. Sometimes, a simple SQL query is more than enough.
Similar claims are made for the Hadoop data-processing framework Spark โ not because it offers its own SQL query mechanism, Spark SQL, but because it provides native data-access methodologies that tend to be less verbose to work with than the competition. Couchbase is touting SQL via N1QL as a way to get results fast while still respecting connectivity with existing BI products.
The real change, though, may come when front-end BI products choose to speak the new native languages of big data. Tableau, for instance, added a Spark SQL connectorย earlier this year โ a possible prelude to deeper integration with Spark. ย
In the meantime, Couchbase is making itself useful to the SQL-based analytics systems out there rightย now.


