<aside>

This section is part of the 5-hour System Design Foundations course by Mukul Raina

SLIDE 25: Why Databases Exist

Section 4: Databases

Databases are the foundation of every system you will design. Every user account, every post, every transaction, every relationship between entities lives in a database. This section covers what you need to know about databases for system design interviews: types, schemas, indexing, consistency guarantees, replication, and sharding.

What We’ll Cover:

  1. Relational databases (SQL)
  2. Schema design, keys, joins, and indexes
  3. ACID properties
  4. Non-relational databases (NoSQL) and their types
  5. SQL vs NoSQL decision framework
  6. Normalization and denormalization
  7. Replication
  8. Sharding

Why Not Just Use Files?

Requirement File System Database
Find user by email Read entire file, search line by line Index lookup, O(log n)
Update one field Rewrite entire file Update single row in place
Concurrent access File locks, corruption risk Transactions, isolation levels
Structured queries Write custom parsing code SQL: SELECT * FROM users WHERE email = ?
Data integrity No enforcement Constraints, foreign keys, types
Crash recovery Partial writes, data loss Write-ahead log, automatic recovery

At small scale (a config file, a small CSV), files work fine. At the scale of any production system (thousands of concurrent users, millions of rows), a database is not optional.

<aside>

Mukul Raina | youtube.com/@mukulraina | slides.mukulraina.com | LinkedIn

</aside>


SLIDE 26: Relational Databases (SQL)