Beginner → Intermediate28 min read· Topic 2.2

NoSQL databases

Document stores, key-value stores, wide-column stores, graph databases, time-series databases, search engines

📦Key Takeaways

  • 1
    NoSQL = Not Only SQL; includes document stores, key-value, wide-column, graph, and time-series databases
  • 2
    NoSQL trades ACID for scalability, flexibility, and performance in specific access patterns
  • 3
    Choose based on access pattern: key-value for simple lookups, document for flexible schema, wide-column for time-series, graph for relationships
  • 4
    Most production systems use polyglot persistence — different databases for different needs

The NoSQL Landscape

NoSQL databases emerged to solve problems that relational databases struggle with: horizontal scaling to millions of QPS, flexible schemas that evolve without migrations, and specialized data models that match specific access patterns better than tables.

The term 'NoSQL' is misleading — it doesn't mean 'no SQL.' It means 'not only SQL.' Many NoSQL databases actually support SQL-like query languages (CQL for Cassandra, N1QL for Couchbase).

NoSQL Database Types

Simple get/set by key. Extremely fast (~100K-1M QPS). Think of it as a giant hash map.

Examples: Redis, DynamoDB, Memcached, etcd.

Use cases: Caching, session storage, feature flags, leaderboards.

Limitations: No complex queries, no joins, limited indexing.

NoSQL vs SQL Decision Matrix

FactorChoose SQLChoose NoSQL
Data modelHighly relational, many joinsFlexible, denormalized
TransactionsMulti-table ACID requiredSingle-entity operations OK
Scale<50K QPS writes>50K QPS writes needed
SchemaStable, well-definedEvolving, varies per record
Query patternsAd-hoc, complex analyticsKnown, optimized access patterns
ConsistencyStrong consistency requiredEventual consistency acceptable
💡Polyglot Persistence
Modern systems use multiple databases: PostgreSQL for user accounts (ACID), Redis for caching, Elasticsearch for search, Cassandra for event logs, Neo4j for social graph. This is called polyglot persistence. Each database is optimized for its specific access pattern.

Advantages

  • Horizontal scaling is a first-class feature
  • Flexible schemas enable rapid development
  • Optimized for specific access patterns
  • Often higher throughput than SQL for targeted workloads

Disadvantages

  • No universal query language
  • Weaker consistency guarantees
  • Denormalization leads to data duplication
  • Each type requires learning its specific data model

🧪 Test Your Understanding

Knowledge Check1/2

Which NoSQL type is best for storing time-series data?