P

PrepStack

Keys & Constraints

A key is the rule that says which rows are different, and a constraint is a rule the database enforces so bad data never gets in. Interviewers ask about keys to see whether you can tell a super key from a candidate key, explain primary versus unique, and say what happens to child rows when a parent row is deleted. After this section you can define each key in one sentence, show it on a small table, and name the points where MySQL and PostgreSQL behave differently.

Topics in this section