CSE Roadmap

Core tier · about 3 hours · 8 parts

Part 2 of 8 · 2 min read

What "NoSQL" really says

A name that began as a hashtag, and the four reasons people left tables behind.

Think of "non-fiction" in a library. It says what a book is not, but it covers biographies, cookbooks and atlases, which have little else in common. "NoSQL" is the same kind of word.

The book "Designing Data-Intensive Applications" explains that the name was not meant for any one technology. It began in 2009 as a catchy hashtag for a meetup about open source, distributed, non-relational databases. It later came to be read as "Not Only SQL".

NoSQL

NoSQL is a loose name for databases that are not relational tables with SQL: key-value, document, wide-column and graph stores.

Example: Redis (key-value), MongoDB (document), Cassandra (wide-column) and Neo4j (graph) are all called NoSQL.

The book lists the forces behind the move.

  1. Scale. A need for more scalability than a relational database easily gives: very large data sets or very high write rates.
  2. Open source. A preference for free software over commercial products.
  3. Special queries. Operations the relational model does not support well.
  4. Schema frustration. Impatience with the strict schemas of tables, and a wish for a more flexible, expressive model.

The book "System Design Interview" describes the same split: relational stores keep data in tables and rows and allow joins, while NoSQL stores fall into four groups (key-value, graph, column and document), and joins are generally not supported. It adds that for most developers relational databases are the best option, since they have worked well for more than 40 years, but that it is worth looking further if the case fits one of these:

  • the application needs very low latency;
  • the data is unstructured, or there is no relational data;
  • the work is only to serialise and deserialise data (such as JSON);
  • a massive amount of data has to be stored.

Seen this way, "SQL or NoSQL?" is not one question. It is several smaller ones: what shape, what questions, what rules, what scale.

Common mistake

Saying "NoSQL is faster". Speed depends on the access pattern and the setup. A key lookup in a key-value store is very fast because it does little. A complex report in the same store may be impossible. Always say what is fast, for which question.

Check yourself:

  • What did the hashtag "NoSQL" originally name?
  • Name two of the four forces that drove the use of non-relational stores.