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
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
| type | stores data as | examples |
|---|---|---|
| Document | JSON/BSON-like documents | MongoDB, CouchDB |
| Key-Value | Simple key → value pairs | Redis, DynamoDB |
| Column-family | Rows with dynamic columns, grouped by column family | Cassandra, HBase |
| Graph | Nodes 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:
Querying with MongoDB
RDBMS vs Document DB
| aspect | rdbms | document db |
|---|---|---|
| Schema | Fixed, defined upfront | Flexible, can evolve per document |
| Relationships | Joins across tables | Often embedded within a document |
| Consistency | Strong (ACID) by default | Configurable, often eventual at scale |
| Scaling | Mostly vertical (bigger server) | Horizontal (sharding across servers) |
| Best for | Structured, relational data | Rapidly 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.