DEV Community

shantanu mahakale
shantanu mahakale

Posted on

Quick Recap: NoSQL Databases

NoSQL databases are built to handle scale, flexibility, and high-speed data processing. They are ideal when data is semi-structured, rapidly changing, or requires horizontal scalability across multiple servers.

Unlike relational databases, NoSQL databases do not strictly follow ACID and often trade consistency for availability and performance (as per the CAP Theorem).


Types of NoSQL Databases & When to Use Them

1. Key-Value Databases

  • Store data as key-value pairs (like a dictionary/map).
  • Best for caching, session stores, user preferences, or quick lookups.
  • Extremely fast reads and writes.

Examples: Redis, DynamoDB, Riak

Use When: You need ultra-fast reads/writes and simple data access by key (e.g., session tokens, caching).


2. Document Databases

  • Store data as JSON/BSON-like documents.
  • Flexible schema — each document can have different fields.
  • Good for real-time apps, product catalogs, user profiles, logs.

Examples: MongoDB, CouchDB, Firebase Firestore

Use When: Data structure is flexible and changes often (e.g., user profiles, content apps, blogs).


3. Column-Based Databases (Wide-Column Stores)

  • Store data column-wise instead of row-wise.
  • Optimized for high write throughput and querying large datasets.
  • Used in analytics, time-series data, and big data workloads.

Examples: Cassandra, HBase, ScyllaDB

Use When: You need high write scalability and distributed data handling (e.g., IoT data, logs, analytics).


4. Graph Databases

  • Store data as nodes and relationships (edges).
  • Excellent for relationship-heavy data like social networks, recommendations, fraud detection.

Examples: Neo4j, JanusGraph, Amazon Neptune

Use When: Relationships between data matter most (e.g., social networks, fraud detection, recommendations).


Summary Table – When to Use What?

NoSQL Type Best For Example Use Cases
Key-Value Fast lookup by key Session store, caching
Document Flexible schema User profiles, blogs
Column-Based Large scale writes & analytics Time-series, telemetry
Graph Relationship modeling Social graphs, fraud detection

CAP Theorem & NoSQL

A distributed system can guarantee only two out of three:

  • Consistency
  • Availability
  • Partition Tolerance
Database Type CAP Focus
Cassandra Column-Based AP
DynamoDB Key-Value AP
MongoDB Document CP (configurable)
Neo4j Graph CP

When Not to Use NoSQL?

Avoid NoSQL when:

  • Strong relationships & joins are needed.
  • Complex transactions (ACID) matter.
  • Data integrity is critical.
  • Schema is fixed and stable.

In such cases → Use Relational Databases (PostgreSQL, MySQL, SQL Server).

Top comments (0)