NoSQL

API Creator supports NoSQL by way of JavaScript (for example, a JavaScript resource or access from other JavaScript events such as business logic). This article considers NoSQL as the "main" database for an API. Recent development warrant another look at this key choice since this Linux Journal article, and Dr. Dobb's "Do All Roads Lead Back to SQL?" article.

NoSQL Motivations

The most commonly held view is that NoSQL provides "scale-out" performance and fault-tolerance through massive parallelism. By contrast, most SQL implementations are single-site, resulting in potential bottlenecks and a single point of failure. Another key advantage of NoSQL is schema flexibility. Most NoSQL implementations do not enforce a pre-defined set of columns for a table, so it is easier to address cases where certain records have extra fields. SQL implementations enforce a schema, which reduces errors but is not as flexible.

While these advantages are well-known, there is a less technical reason. We are in the midst of a shift to mobile and NoSQL is simpler for mobile developers, for the following reasons:
  • Most NoSQL systems speak REST/JSON out-of-the-box. SQL, by contrast, requires a pile of work to assemble and integrate frameworks that provide the REST listeners, database/JSON mappings, and so forth.
  • No schema to define. Instead, store your JavaScript objects.
  • These further often support a "document model" where nested data (a list of orders nested within a customer), which is a more natural programming model.
  • Many implementations provide for server code in JavaScript, a common mobile language.

SQL Motivations

NoSQL looks like fun. It is faster, more flexible, and easier to program. SQL has advantages, but it seems like they are a bit more like what you should do than what you want to do.

One of the biggest advantage of SQL is atomicity, consistency, isolation, and durability (ACID) transaction supportTransactions (grouped sets of updates over multiple tables) are atomic. They all succeed or nothing is changed. This addresses an exception-handling mechanism that is common over many systems, such as an order which affects a customer a set of of parts.

SQL provides a more powerful query capability, with all manner of multi-table joins and group-bys. It is a long-standing standard, so many tools supported it, such as report writers and analytic tools.

Recent Developments

Most analyses conclude that there is a place for SQL and NoSQL. Recent developments have a substantive effect on the evaluation. In particular, SQL has seen advances in performance/fault-tolerance, and mobile app development simplicity.

The rise of NewSQL is focused on performance/fault-tolerance. These are conceived on the premise that SQL is a interface definition and there is nothing in SQL that prevents an implementation from delivering remarkable performance through in-memory techniques (SAP Hana) or massive parallelism (NuoDB). There are also hybrid approaches that provide ACID support with SQL-ish query (for example, Google F1).

Regarding simplicity for mobile app developers, multiple vendors, such as Microsoft and CA Live API Creator, provide REST out-of-the-box and support for nested resource definitions. API Creator supports JavaScript logic and declarative reactive logic for business logic.

The schema-flexibility matter has been routinely addressed within SQL, with approaches like "blob with xml/JSON for extended attributes" or other techniques. These can enforce the schema for the known-in-advance data, with flexibility as required. You need to learn Data Definition Language (DDL) for schema definition.