Distributed

Lesson 02.8

Constraints as the final boundary

Database constraints enforce rules at the shared source of truth, catching invalid data even when application checks race or are bypassed.

Two players, one name

A game keeps a list of players. Ava and Ben both sign up at the same time, and both want the name Sam 🎮.

The game can turn on a 🛡️ rule inside the list itself: “no two players can have the same name.”

In this lesson you'll

  1. 1Watch a normal sign-up.
  2. 2Guess what the 🛡️ rule does when both sign up at once.
  3. 3Turn the rule off and see what it was protecting.