Your Cart
Loading

Primary vs Foreign Keys Workbook (Database Design Lesson 1)

On Sale
$2.00
$2.00
Added to cart

Most students can define a primary key. Fewer can say why a name can't be one, or which side of a relationship the foreign key belongs on. This workbook covers both, in the order an instructor would teach them.


The 3 problems

  1. Easy: given a student table with unique emails and repeated names, list every candidate key, pick the primary key, and explain why Name fails.
  2. Medium: one instructor teaches many sections. Where does the foreign key go?
  3. Hard: with foreign keys turned on, decide which INSERT statements the database will reject, then run them to check.


Details: 16 pages and 8 tested queries. Includes the PRAGMA foreign_keys = ON setup step that SQLite needs and many tutorials skip.


Next in the series: Database Design Lesson 2, Many-to-Many Relationships.

You will get a PDF (77KB) file