Skip to main content

32 docs tagged with "database"

View all tags

Backend

A hub for the domain that collects notes on server-side development, including API design, authentication, and databases. It covers business logic design, data persistence, and building APIs.

Chapter 18: Database Normalization Exercises

A collection of exercises to deepen the understanding of normalization covered in Chapter 11. Practice decomposing an unnormalized table up through third normal form, repeatedly, using common business cases (children's information, multiple categories, derived values, employee information).

Data distribution — what breaks after you spread it out

This chapter covers what replication and sharding gain and break. It explains the difference between sync and async, why you can't read what you just wrote, skew in partition keys, when eventual consistency shows up, and reading CAP as "what to give up during a partition".

Design Template Collection — Database Design Guide

A collection of design templates and checklists that junior engineers can bring into real projects. It lists out naming conventions, normalization, key design, and review criteria, so you have something to check against right away on a new project.

Domain Model and Table Design — Mapping and Indexes

Covers why to design domain-model-first, mapping patterns under the premise that the domain model and tables are not 1:1 (embedding / one aggregate across multiple tables / technical splitting), how the repository absorbs the gap, and index design including the leftmost-prefix rule for composite indexes and its trade-offs.

Glossary — Database Design Guide

A quick-reference dictionary of the technical terms that appear throughout this guide. When you're reading a chapter and wondering "what was the definition of that term again?", check here for a quick answer.

Indexes — the cost of making lookups faster

This chapter explains how indexes speed up lookups and the cost they impose on writes. It covers column order in composite indexes, patterns that stop indexes from being used, and how they differ from sharding and hashing.

Joins and aggregation — one answer from many tables

This chapter covers reading and writing queries that join and aggregate across tables. It covers the evaluation order of SELECT, the difference between inner and outer joins captured as row-count changes, one-to-many increasing parent rows, GROUP BY granularity, the difference between COUNT(*) and COUNT(column), NULL three-valued logic, and triaging "the count doesn't add up".

Locks and isolation levels — controlling concurrent execution

This chapter explains shared and exclusive locks, the four transaction isolation levels and three read anomalies, the choice between optimistic and pessimistic locking, and the causes and avoidance of deadlocks. It covers how to hold a version column in the table and why raising the isolation level alone doesn't prevent contention without locks.

Subqueries and window functions — counting across rows

This chapter covers the three positions where subqueries fit, correlated subqueries and EXISTS, writing in reading order with CTEs, and how window functions aggregate without folding rows. It covers the differences between ROW_NUMBER, RANK, and DENSE_RANK, running totals, top-N per group, and support versions per database.

Transaction Management — Where to Place the Consistency Boundary

Explains transaction management using Laravel's DB::transaction(). Covers the ACID properties, when to place transactions inside the Repository (single aggregate) versus the UseCase (multiple aggregates), nested transactions (savepoints), and the implementation and use cases of optimistic and pessimistic locking.

Transactions — ACID, commit, and rollback

This chapter covers the three basic operations of a transaction (begin, commit, rollback) and the four ACID properties. It explains that rollback affects only your own transaction, that commits can't be undone, and when syntax errors are detected.