Databases

NoSQL DBMS / Document DB

NoSQL database families — document, key-value, column, and their trade-offs versus relational databases — with MongoDB examples.

  • NoSQL
  • MongoDB
  • Database Design
NoSQL document database illustration

What is NoSQL?

NoSQL (“Not Only SQL”) databases store data without the rigid table/row structure of an RDBMS. They trade some of SQL’s strict consistency and joins for flexible schemas and horizontal scalability — useful when data is unstructured, rapidly evolving, or needs to scale across many servers.

The Main NoSQL Families

NoSQL categories
typestores data asexamples
DocumentJSON/BSON-like documentsMongoDB, CouchDB
Key-ValueSimple key → value pairsRedis, DynamoDB
Column-familyRows with dynamic columns, grouped by column familyCassandra, HBase
GraphNodes and edges (relationships)Neo4j, ArangoDB

This note focuses on Document databases, the most commonly used NoSQL family for general application data.

Document Model Example

Instead of splitting an order across orders, order_items, and customers tables, a document database can embed related data directly:

order.json

Querying with MongoDB

queries.js
RDBMS (normalized)ordersitemscustomersjoined at query timeDocument (embedded)order (customer, items[])one document, one read

RDBMS vs Document DB

When to pick which
aspectrdbmsdocument db
SchemaFixed, defined upfrontFlexible, can evolve per document
RelationshipsJoins across tablesOften embedded within a document
ConsistencyStrong (ACID) by defaultConfigurable, often eventual at scale
ScalingMostly vertical (bigger server)Horizontal (sharding across servers)
Best forStructured, relational dataRapidly evolving, nested/unstructured data

When to Choose NoSQL

  • The schema changes frequently or varies between records (product catalogs with wildly different attributes).
  • You need to scale writes horizontally across many nodes.
  • Data is naturally hierarchical/nested and rarely needs joining across collections.

When to Stay Relational

  • Data integrity and multi-table consistency matter (financial transactions).
  • The domain has many well-defined relationships queried in different directions.
  • The team already has strong SQL tooling and reporting built around it.

Many real systems use both — an RDBMS for transactional core data, and a document store for logs, catalogs, or flexible user-generated content.