Last Minute Notes

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.

  1. 01
    Database 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.

  2. 02
    SQL 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.

  3. 03
    SQL 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.

  4. 04
    Indexing 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.

  5. 05
    Transactions 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.

  6. 06
    Database 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.

  7. 07
    Replication, 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.

  8. 08
    NoSQL 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.

  9. 09
    Data 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.

  10. 10
    Database 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.

Reading Path

Pick Your Level

You areRead in this order
New to databasesFundamentals, SQL Essentials, SQL Practice Problems
Preparing for a mid-level loopAdd Indexing, Transactions, Data Modeling
Preparing for senior or staffAdd Internals, Replication and Sharding, NoSQL
One week leftThe Interview Playbook study plan
  • 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.

On this page