Skip to content
skillbld
Day 6 of 14 35 minPRIMARY KEYFOREIGN KEYUNIQUECHECK

Let the database protect your data. Use primary keys, foreign keys, UNIQUE, CHECK and NOT NULL so bad data can't get in, and split data into related tables.

By the end of today you can

  • Explain primary keys and foreign keys
  • Split data into related tables instead of repeating it
  • Enforce rules with NOT NULL, UNIQUE and CHECK
  • Read constraint errors and understand what they protect
  • Choose what happens on delete with ON DELETE

What's inside

  • 5 sections
  • 3 diagrams and mind maps
  • 7 code examples you can run
  • 5-question quiz
  1. 1Why split data into tables?
  2. 2Primary keys and foreign keys
  3. 3Constraints in action
  4. 4What happens on delete?
  5. 5Many-to-many: a join table

Sign in free to read this lesson

Get the full lesson with diagrams, runnable code and the quiz. Your progress is saved across devices.

Sign in free
Day 6: Constraints & Keys · PostgreSQL · SkillBld