Before you pick a Candidate Key or a Primary Key, you are technically dealing with Super Keys.
Super Key: A set of one or more columns that can uniquely identify a record in a table. It is the most "general" type of key.
This is a common interview "trap" question. The difference lies in Minimality.
- Super Key: Any combination of columns that is unique. (e.g.,
Employee_ID + Employee_Name). This is unique, but it contains "extra" information (Name) that isn't strictly needed for uniqueness. - Candidate Key: A Minimal Super Key. It is the smallest possible set of columns that can uniquely identify a row. (e.g.,
Employee_IDon its own).
SUPER KEYS (All unique combinations)
βββ CANDIDATE KEYS (Minimal unique combinations)
βββ PRIMARY KEY (The one chosen by the DBA)
Super Keys are the starting point of database design. You identify all unique combinations (Super Keys), trim them down to the smallest unique versions (Candidate Keys), and then select your official identifier (Primary Key).
- Task 1: If
IDis unique, is(ID, Name)a Super Key? Is it a Candidate Key? - Task 2: "All Candidate Keys are Super Keys, but not all Super Keys are Candidate Keys." Explain why this statement is true.