Database Architecture Explained: How a DBMS Works
A database is a stack: connection, parser, optimizer, executor, buffer pool, log and files. Follow one query through every layer.
In this chapter
A database is a stack, not a single store
More on Storage engine
Keep learning
Overview
chapters · storage engine A database is a stack, not a single store Hot session data, a long-lived order table, an analytics scan, and a time series are different jobs. No one layout is best at all of them. This chapter is the map. Later chapters open each box.
SQL arrives at the top. Pages live at the bottom.
From the application it looks like one hop: SQL in, rows out. Inside, the statement passes through layers, each with one job. Real systems blur the lines. The split is still the one to keep. Below the storage engine is the disk or the SSD. A memory store keeps the working set in RAM and still uses disk when it must survive a power loss.
The optimizer picks a plan
The parser checks that the statement is legal and what it asks for. Access checks can run once that meaning is known. Then several plans may answer the same question. No index Read the table until the email shows up. On 100 million rows, that is a scan. Index on email Find the key in the index, then read that record. The optimizer uses row counts, indexes, and where the data sits to choose. The path is parser, then a logical form, then statistics, then a plan, then the execution engine. EXPLAIN shows the plan that won.
The execution engine runs the plan. The storage engine holds the records.
The optimizer decides what to do. The execution engine does those steps. The storage engine returns pages and records. MySQL keeps that split visible: the server can sit on InnoDB, MyISAM, or MyRocks. InnoDB is the one these chapters keep returning to, because it has transactions, a buffer pool, and a B-tree.
Five jobs inside the storage engine
A transfer is two updates that must land together. Two sessions must not both spend the same balance. Finding a row is a heap, a B-tree, or an LSM tree. Disk is slower than RAM, so hot pages stay in a buffer. A commit is recorded in a log so a crash can rebuild the page. Who does which job Transaction manager The two balance updates commit together, or neither does. Lock manager Two transactions updating account 1 take turns. Access methods Heap file, B-tree, or LSM tree. Chapters 25–27 open the B-tree. Buffer manager Keeps useful pages in RAM. InnoDB calls this the buffer pool. Recovery manager Log, then checkpoint, then replay after a crash.
A memory database is not a disk database with a huge cache
The full database lives on SSD. RAM holds the hot pages. MySQL and PostgreSQL are built this way. In memory The working set is designed for RAM. Redis and Dragonfly still write a log or a snapshot when the data must survive power loss. Pointers, layout, and concurrency can differ because a memory access is not a page read. RAM forgets SET user:1 "John" when the machine dies. One fix is to append that operation to a sequential log before calling it done, and to fold the log into a snapshot on a schedule. Recovery is the snapshot plus the log that came after it. Once a change is in the snapshot, the older log can be thrown away. That trio is log, checkpoint, recovery.
Row layout serves one record. Column layout serves one aggregate.
Salaries sit in one run: 100000, 120000, 150000. AVG(salary) reads that run and leaves the other 49 columns on disk. Aggregations over large scans are the workload this layout is for. Name the workload before the product Layout that fits Short transactions: create an order, update an account, fetch a user Scans and aggregates: SUM and AVG grouped by region The same system tries to serve both A mix, with a cost on each side
Choose from the workload, not from the logo
Popularity, language, and one famous component are weak reasons. The useful questions are about the data and the clients. RecordsHow wide, and how many? ClientsHow many, and how many operations per node? QueriesPoint reads, updates, or scans? MixRead/write ratio, and how it grows. BarLatency, consistency, and how the cluster will grow. The next chapters stay on one node: pages, the B-tree, the buffer, and the log. Several nodes come after that: replication, consistency, and consensus.
More courses
- Jobs, linked to lessons — Browse jobs where every requirement links to the chapter that teaches it. See how ready you are, how long the gap takes to close, and which listings look stale.
- Match a job post to courses — Paste a job post. Each skill is matched to a track here and put in learning order, foundations first.
- React patterns from open source — Patterns extracted from Material UI, Radix, React Aria, React Hook Form, Redux Toolkit, TanStack, and Next.js — not slides about hooks.
- System Design — Core concepts first (SQL vs NoSQL, CAP, indexing, replication, sharding), then designs grouped by what carries them: the database, Redis, Kafka, or many services.
- NestJS: build a real API — One ticket-booking API, built in order: a plain Node server first, then NestJS modules, validation, a real database, and the features real clients lean on.
- Microservices — Microservice patterns one diagram at a time: how to split a monolith, how services talk, and how data stays consistent without distributed transactions.
- Kafka — A beginner-to-senior path through event logs, reliable delivery, production operations, and disaster recovery.
- AI engineering for software engineers — Eight free reads, in order, for software engineers moving into AI: when to build an agent, how to build one, how to test it, and how the model works underneath.
- Frontend system design — How a UI is sliced when it is a product, not a page: ownership of state, cache, routes, and what happens when the network lies.
- TypeScript in depth — The type system as a design tool. Inference, narrowing, generics, and the errors that mean the model is wrong — not a catalog of utility types.
- CSS in depth — See the box, then the page. Visual chapters from the box model through Flexbox surprises, Grid, selectors, and units, then backgrounds, shapes, and visual effects, each with a playground.
- Accessibility — Foundations first (WCAG in plain words, semantic HTML, lists, alt text), then hands-on HTML labs, a full pass of WAI-ARIA 1.3, and a final fix-the-page challenge.
- Docker — What an image is, why layers cache, and how containers find each other on a network.
- Redis — Fifteen Redis patterns, one picture each: cache, session, lock, counter, rate limiter, queue, and when Redis is the wrong tool.
- Kubernetes — Kubernetes from zero to operators: why it exists, Pods, Deployments and Services, then configuration, networking, storage, scheduling, scaling and security.
- AWS — AWS networking in plain English. A VPC is a gated housing society: streets are subnets, the Internet Gateway is the main gate, and a route table is the signboard.
- Networking: the NetRoute game — NetRoute is a packet logistics game. You wire up computers, switches, routers, firewalls and gateways, set each device, and watch glowing packets travel. If a packet gets dropped, the game shows you which header field was wrong.