Chapter 4: CRUD and ACID — Mechanisms for Safely Getting Data In and Out
This chapter explains the four basic database operations (CRUD), and the transactions and ACID properties (atomicity, consistency, isolation, durability) that handle multiple operations as a unit, using examples like bank transfers.
Chapter 5: Introduction to Relational Databases — Why Handle Relationships With Tables
This chapter explains, for junior engineers, the basic concept of a relational database (RDB), the benefits and trade-offs of managing data as "multiple related tables" instead of "one giant table," and how to choose between RDB and NoSQL.
Chapter 6: DBMS and SQL — The Mechanism and Common Language for Operating Data
This chapter explains, for junior engineers, the role of a DBMS (SQL parsing, transaction management, permissions, optimization), the four categories of SQL (DDL/DML/DCL/TCL), and the characteristics and trade-offs of major RDBMS products (PostgreSQL / MySQL / SQLite / Oracle / SQL Server).
インデックス — 検索を速くする代償
インデックスが検索を速くする仕組みと、その代わりに払う更新時のコストを解説します。複合インデックスのカラム順序、インデックスが効かない書き方、シャーディングやハッシングとの用語の区別を扱います。
サブクエリとウィンドウ関数 — 行をまたいで数える
サブクエリを置ける 3 つの位置、相関サブクエリと EXISTS、CTE で読む順に書く方法、そしてウィンドウ関数が行を畳まずに集計する仕組みを扱います。ROW_NUMBER と RANK の違い、累計、グループごとの上位 N 件の出し方と、各データベースの対応バージョンを示します。
トランザクション — ACID とコミット・ロールバック
トランザクションの基本操作 (開始・コミット・ロールバック) と ACID の 4 特性を解説します。ロールバックが取り消す範囲が自分のトランザクションに限られること、コミット後は取り消せないこと、構文エラーが発生するタイミングを扱います。
結合と集計 — 複数の表から 1 つの答えを作る
複数のテーブルを結合して集計するときの読み書きを扱います。SELECT の評価順序、内部結合と外部結合の違いを行の増減で捉える見方、1 対多で親の行が増えること、GROUP BY の粒度、COUNT(*) と COUNT(列) の違い、NULL の三値論理と「件数が合わない」ときの切り分けを扱います。