MongoDBDatabases

What Is NoSQL? Database Models Compared

Understand NoSQL database types: document, key-value, column-family, and graph. Learn when to choose NoSQL over relational and where MongoDB fits. Lesson 1 of the MongoDB & NoSQL Mastery course.

TT
Sarah Mitchell
5 min read
What Is NoSQL? Database Models Compared

NoSQL does not mean "no SQL" — it means "not only SQL." The term covers a broad family of databases that reject the relational model's fixed schema and table structure in favour of data models better suited to specific access patterns. Understanding the landscape before choosing a database prevents the most expensive architectural mistake: picking the wrong storage engine for your workload.


Why NoSQL Emerged

Relational databases — PostgreSQL, MySQL, Oracle — have dominated data storage for four decades. They are excellent tools. But at web scale, three constraints become painful:

  • Schema rigidity: every row must conform to a fixed schema; changing it requires a migration that locks tables
  • Horizontal scaling: relational databases scale vertically (bigger servers) more easily than horizontally (more servers); sharding is complex and expensive
  • Impedance mismatch: application objects — nested, polymorphic, variable-shape — must be decomposed into normalised tables and reassembled on every read

NoSQL databases trade some of the guarantees of the relational model (typically ACID across multiple tables) for flexibility, horizontal scalability, and a data model that matches how applications think about data.


The Four NoSQL Database Models

Document Databases

Documents are self-contained records expressed as JSON (or BSON in MongoDB's case). A document can contain nested objects and arrays — an entire order, with line items and shipping address, in a single record.

DatabaseNotes
MongoDBMost widely adopted; rich query language and aggregation pipeline
CouchbaseBuilt-in caching layer; SQL-like query language (N1QL)
Amazon DynamoDBManaged AWS service; also supports key-value access patterns
Google FirestoreServerless; tight integration with Firebase/GCP

Best for: content management, product catalogues, user profiles, event logging, any workload where each record is naturally a self-contained object.

Key-Value Stores

The simplest model: a hash map. Each value is opaque — the database stores and retrieves it by key with no awareness of its structure.

DatabaseNotes
RedisIn-memory; supports rich data structures (lists, sets, sorted sets, hashes)
Amazon DynamoDBSupports key-value at massive scale with predictable single-digit millisecond latency
etcdDistributed key-value store used by Kubernetes for cluster state

Best for: session storage, caching, leaderboards, rate limiting, feature flags, real-time pub/sub.

Column-Family (Wide-Column) Stores

Data is stored by column rather than by row. Each row can have a different set of columns, and columns are grouped into families. Optimised for writes at massive scale and time-series data.

DatabaseNotes
Apache CassandraDecentralised; no single point of failure; used by Netflix, Apple
Apache HBaseHadoop ecosystem; modelled on Google Bigtable
Google BigtableManaged GCP service; petabyte scale

Best for: IoT sensor data, time-series analytics, write-heavy workloads at massive scale, click-stream data.

Graph Databases

Data is modelled as nodes (entities) and edges (relationships). Traversing relationships is a first-class operation — far more efficient than recursive SQL joins.

DatabaseNotes
Neo4jMost mature graph database; Cypher query language
Amazon NeptuneManaged AWS service; supports Gremlin and SPARQL
ArangoDBMulti-model: document + graph + key-value in one

Best for: social networks, recommendation engines, fraud detection, knowledge graphs, identity and access management graphs.


NoSQL vs Relational: Choosing the Right Tool

CriterionRelational (PostgreSQL, MySQL)NoSQL (MongoDB, Redis, etc.)
SchemaFixed, enforcedFlexible, optional
RelationshipsFirst-class (foreign keys, joins)Application-managed or embedded
TransactionsFull ACID across many tablesVaries; MongoDB supports multi-document ACID since v4.0
ScalingPrimarily vertical; horizontal is complexDesigned for horizontal sharding
Query languageSQL — powerful, standardisedDatabase-specific
ConsistencyStrong by defaultConfigurable (eventual to strong)
Best fitFinancial records, ERP, normalised domainsHierarchical data, high-write workloads, flexible schemas

The real question is not "SQL or NoSQL" — it is "what are my access patterns?" Design your storage layer around how your application reads and writes data, not around how data is logically related in the abstract.


Where MongoDB Fits

MongoDB is a document database — the most versatile NoSQL model for general application development. It occupies the space between a pure key-value store (too simple for complex queries) and a relational database (too rigid for flexible schemas).

MongoDB's strengths:

  • Rich query language: filter, project, sort, and paginate with a native query API
  • Aggregation pipeline: multi-stage data transformation equivalent to SQL's GROUP BY, HAVING, and window functions
  • Flexible schema: fields can be added without migrations; documents in the same collection can have different shapes
  • Horizontal scaling: built-in sharding across multiple nodes
  • ACID transactions: multi-document, multi-collection transactions since MongoDB 4.0

MongoDB's limitations:

  • No cross-collection joins (use $lookup in the aggregation pipeline — but it is expensive)
  • No enforced referential integrity between collections
  • Memory usage is higher than column stores for analytical workloads
  • Not ideal for highly relational data where many-to-many relationships dominate

ACID in NoSQL Context

A common misconception: NoSQL databases are not ACID-compliant. In reality, most modern NoSQL databases offer ACID guarantees at some level:

  • MongoDB: ACID at the single-document level since v1.0; multi-document ACID transactions since v4.0
  • DynamoDB: ACID at the single-item level; transactions available via TransactWriteItems
  • Cassandra: Lightweight transactions (compare-and-set) via Paxos; eventual consistency by default
  • Redis: Atomic operations on individual data structures; MULTI/EXEC for batched operations

For most application workloads, MongoDB's single-document ACID guarantee is sufficient — because a well-designed document schema embeds related data, eliminating the need for cross-document transactions.