Defining Tables

A table definition is a contract that MySQL 524 enforces on every write, whichever client sends it: column types, NOT NULL, unique keys, CHECK expressions and foreign keys. This section builds and alters the bookshop schema below, which sample-db.sql loads and the rest of the chapter queries. Data Types chose its types; Design and Normalization explains why it has these six tables, and Indexes indexes them.

The bookshop schema: six tables, with arrows from each foreign key to the key it references
The bookshop schema: six tables, with arrows from each foreign key to the key it references

Subsections