Lesson 2.24mIntermediate9.4k students

Constraints, keys, and integrity

Constraints are guarantees the database keeps even when a buggy deploy does not. Foreign keys, uniqueness, and checks belong in the schema.

This lesson sits in Schema Design, part of PostgreSQL for Developers. It assumes what came before it and leads directly into the next lesson in the module.

In this lesson you will

  • Enforce relationships with foreign keys
  • Use unique and check constraints as invariants
  • Choose delete behaviour deliberately

Resources