Search IOCombats

Search challenges, guides, questions and articles

System DesignTopic 8 of 12BeginnerApr 5, 2026

Databases

Learn different types of databases, when to use them, and how they impact scalability, performance, and system design decisions.

system-designdatabasesbackend

Why It Matters

Database is the core of your system.

Every request eventually reads or writes data.

If your database design is wrong:

  • system becomes slow
  • scaling becomes difficult
  • data inconsistencies happen

Most system design decisions revolve around database choices.

What This Concept Actually Means

A database stores and manages application data.

Different databases are optimized for different use cases.

Choosing the right one is critical.

How It Works

Let’s take an e-commerce system.

  • Users place orders
  • Products are listed
  • Payments are processed

Different parts of system need different databases.

Example:

  • Orders -> SQL database
  • Product catalog -> NoSQL database
  • Search -> Search engine

Flow:

Diagram
100%
flowchart LR User --> API API --> SQLDB API --> NoSQLDB API --> SearchEngine
visualized byIOCombats

Key Techniques / Variations

1. Relational Databases (SQL)

Examples:

  • MySQL
  • PostgreSQL

Characteristics:

  • structured schema
  • strong consistency
  • supports transactions

Use cases:

  • banking systems
  • order management

Example:

  • 1,000 transactions per second with ACID guarantees

2. NoSQL Databases

Types:

Key Value Stores

Examples:

  • Redis

Use cases:

  • caching
  • session storage

Document Databases

Examples:

  • MongoDB

Use cases:

  • flexible schemas
  • user profiles

Column Family

Examples:

  • Cassandra

Use cases:

  • large scale write-heavy systems

Example:

  • handles millions of writes per second

Graph Databases

Examples:

  • Neo4j

Use cases:

  • social networks
  • recommendation systems

3. Search Databases

Examples:

  • Elasticsearch

Use cases:

  • full text search
  • filtering and ranking

Example:

  • search results in 50 ms to 100 ms

4. Time Series Databases

Examples:

  • InfluxDB

Use cases:

  • metrics
  • monitoring systems

Trade-offs and Design Decisions

When to use SQL

  • need transactions
  • structured data

When to use NoSQL

  • need scalability
  • flexible schema

Pros of SQL

  • strong consistency
  • reliable transactions

Cons of SQL

  • harder to scale horizontally

Pros of NoSQL

  • high scalability
  • flexible schema

Cons of NoSQL

  • weaker consistency in some systems

Real-world example

  • SQL DB handles 2,000 writes per second
  • Traffic grows to 10,000 writes per second

Solution:

  • move to sharding or NoSQL

Architecture / Flow Diagram

Diagram
100%
flowchart LR Client --> API API --> SQLDB API --> Cache API --> NoSQLDB
visualized byIOCombats

Failure Modes To Watch

  • database bottleneck
  • slow queries
  • lack of indexing
  • data inconsistency in distributed systems
  • poor schema design

Design Checklist

Ask yourself:

  • What type of data am I storing?
  • What is read vs write ratio?
  • Do I need strong consistency?
  • What is expected scale? (e.g., 1k vs 1M requests per second)
  • Do I need multiple databases?

Summary

  • Database choice impacts scalability and performance
  • SQL is best for transactions and structured data
  • NoSQL is best for scale and flexibility
  • Different databases serve different purposes
  • Real systems often use multiple databases together

Advertisement

Related Videos
Watch these videos to reinforce the topic after reading the guide.
Frequently Asked Questions

Which database should I choose for my system?

It depends on your use case. SQL is good for structured data and transactions, while NoSQL is better for scalability and flexible schemas.

Can I use multiple databases in one system?

Yes. Many systems use polyglot persistence where different databases serve different needs.