Databases
What is NoSQL?
Definition
NoSQL is an umbrella term for databases that do not use the relational table model, including document, key-value, wide-column and graph stores.
Also known as: Non-relational database
NoSQL in more detail
The name is a poor description of a real category. It arose around 2009 for systems built to scale horizontally across commodity machines when a single relational server had become the bottleneck, and it now covers designs with little in common beyond not being tables. It is commonly read as 'not only SQL', which is fairer, since several of these systems have since added SQL-like query languages.
Four shapes dominate. Document stores such as MongoDB and Couchbase hold JSON-like records and suit data that is read as a whole. Key-value stores such as Redis and DynamoDB offer extremely fast lookups by key and little else. Wide-column stores such as Cassandra and HBase spread enormous tables across many nodes with a partition key that decides placement. Graph databases such as Neo4j make relationships first-class, so traversing many hops stays cheap where a relational join would not.
Two beliefs about NoSQL are outdated. Schemaless does not mean no schema — it means the schema is enforced by your application instead of the database, so mixed record shapes accumulate and every reader must cope. And eventual consistency is not inherent: DynamoDB, MongoDB and Cassandra all offer strong or tunable consistency now. Meanwhile relational databases gained first-class JSON columns, so 'I need flexible fields' stopped being a reason to leave them.
NoSQL example
Document (MongoDB) — the whole record in one place
db.orders.insertOne({
_id: "8842",
user: { id: 12, email: "a@b.com" },
items: [ { sku: "A1", qty: 2 } ],
total: 49.00
})
db.orders.find({ "user.id": 12, total: { $gt: 20 } })
Key-value (Redis) — fast by key, nothing else
SET session:8f2c '{"user_id":12}' EX 1209600
GET session:8f2c
Wide-column (Cassandra) — the partition key decides everything
PRIMARY KEY ((user_id), created_at)
-- queries must lead with user_id; ad-hoc filters are not free
Graph (Cypher) — relationships are the data
MATCH (a:User)-[:FOLLOWS*2]->(suggested) RETURN suggestedNoSQL — common questions
- Is NoSQL faster than SQL?
- Only for the access patterns it was designed around. A key-value lookup beats a relational query on the same hardware, while an ad-hoc join across three entities is far easier and often quicker in a relational database.
- Does NoSQL mean no schema?
- No. It means the database does not enforce one, so responsibility moves to your application code. Records of several shapes end up in the same collection over time, and every reader has to handle all of them.
- When should I choose NoSQL over a relational database?
- When the access pattern is genuinely known and narrow — key lookups at very high volume, deep graph traversal, time-series ingestion, or write volumes past what one relational primary can take. For general application data, relational remains the safer default.
Keep reading
Every definition in the set is indexed A-Z in the developer glossary, and the cheat sheets cover the syntax once you know what you are looking for.
Browse the A-Z glossary