Lesson 2.2

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.

3mIntermediate9,433 students
Video thumbnail for Constraints, keys, and integrity

Sign in to watch this lesson

Browsing is free. Create an account to play videos and track your progress.

Overview

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

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