Databases
A beginner to advanced database library: relational fundamentals, SQL from basics to window functions, indexing, transactions and isolation, internals, replication and sharding, NoSQL, data modeling, and an interview question bank. SQL examples were executed.
Start here for database prep, from "what is a primary key" to "how does MVCC work" and "how do I shard Postgres". The focus is relational databases first (PostgreSQL, MySQL, SQLite), because that is what most interviews and most production systems use, then NoSQL and analytics. Every portable SQL example on these pages was run against SQLite, and Postgres-only syntax is labelled. Facts that changed recently (PostgreSQL 18, MySQL 9.7 and vectors, DynamoDB multi-Region strong consistency, Postgres as the default engine) are included where they matter.
- 01Database Fundamentals
Beginner database concepts: what a DBMS is, the database landscape, the relational model, keys and constraints, relationships, ER diagrams, normalization and denormalization, data types, NULL semantics, OLTP vs OLAP, and how to choose a database.
Beginner - 02SQL Essentials
SQL from beginner to advanced: logical query order, filtering, joins, aggregation, subqueries, CTEs and recursive CTEs, window functions, set operations, DML with upsert and RETURNING, dialect differences, and common mistakes. Every example was run.
Beginner to mid - 03SQL Practice Problems
Twenty classic SQL interview problems with executed solutions: second highest salary, top N per group, median, gaps and islands streaks, retention, date series, overlapping and merged intervals, deduplication, pivot and unpivot, plus a pattern map.
Mid - 04Indexing and Query Performance
How database indexes work and how to make queries fast: B-tree lookups, index types, composite index column order, covering and partial indexes, reading EXPLAIN, sargability, statistics, N+1, pagination, and index maintenance. Query plans were executed.
Mid - 05Transactions and Concurrency
Database transactions from ACID to advanced: isolation levels and anomalies, MVCC, locking, SELECT FOR UPDATE and SKIP LOCKED, deadlocks, optimistic and pessimistic concurrency, write skew, inventory and booking patterns, durability with the WAL, and retries.
Mid to advanced - 06Database Internals
How databases work inside: architecture, pages and the buffer pool, B+trees, LSM trees with a runnable toy implementation, write-ahead logging and crash recovery, query planning, join algorithms, execution models, columnar storage, and probabilistic data structures.
AdvancedTable of Contents1. Architecture of a Relational Engine2. Pages, Heap Files and the Buffer Pool3. B+Trees in Depth4. LSM Trees5. Write-Ahead Logging and Recovery6. Query Processing7. Join Algorithms8. Execution Models9. Columnar Storage10. Probabilistic and Specialized Structures11. Questions and Answers - 07Replication, Sharding and Operations
Running databases at scale: replication and lag, high availability and failover, connection pooling, partitioning, sharding with Citus and Vitess, backups and point-in-time recovery, zero-downtime migrations, monitoring, security, and managed services.
Advanced - 08NoSQL Databases
NoSQL in depth: Redis and Valkey data structures and patterns, MongoDB document modeling and sharding, DynamoDB single-table design and global tables, Cassandra data modeling and consistency levels, search, graph, time-series and vector databases, and how to choose.
Mid to advanced - 09Data Modeling Patterns
Practical schema design patterns: the modeling process, order snapshots and money, RBAC, hierarchies (adjacency list, closure table, materialized path), history and SCD Type 2, double-entry ledgers, multi-tenancy, JSON attributes, and star-schema analytics. SQL examples were executed.
Mid to advanced - 10Database Interview Playbook
Database interview preparation: a 60-question bank from beginner to advanced with pointers, schema design prompts, production incident scenarios with a triage flowchart, cheat sheets, common mistakes, and 4-week and 7-day study plans.
All levels
Reading Path
Pick Your Level
| You are | Read in this order |
|---|---|
| New to databases | Fundamentals, SQL Essentials, SQL Practice Problems |
| Preparing for a mid-level loop | Add Indexing, Transactions, Data Modeling |
| Preparing for senior or staff | Add Internals, Replication and Sharding, NoSQL |
| One week left | The Interview Playbook study plan |
Related Sections
- System Design uses these ideas at architecture level: sharding, replication, consistency, CAP.
- Backend covers how application code talks to databases: pools, ORMs, transactions, migrations.
- Java has the JDBC-adjacent collections and concurrency notes.