>_ IzzyLab

Topic breakdown

A foreign key (REFERENCES) links a child column to the parent's primary key and won't let you insert a dangling reference — this is the foundation of referential integrity. The ON DELETE rule defines the behavior when the parent is deleted: by default Postgres forbids deletion while references exist, while the cascade variant, instead of an error, itself deletes the related child rows — convenient but dangerous. Creation order matters: the referenced table must exist before the child one. The delete rule is visible in the Foreign-key constraints section when describing the table.

What's checked

  1. FK on books with ON DELETE CASCADE

What it looks like