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.

Lesson 2.23m 53sIntermediate9.4k students

Chapters

3:53
  1. 0:00Introduction
  2. 0:21Example of Foreign Keys in a database
  3. 0:32What is a Primary key?
  4. 1:19What is a foreign key?
  5. 2:02What do foreign keys do?
  6. 3:27Review of Foreign Keys

What this lesson covers

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

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