Foreign Needs Primary?

A foreign key is a pointer to a unique matching (parent) record. 99.9% of the time, the foreign key matches the primary key of the parent record.

Technically, however, the relational database model allows us to link the parent and child records with a field (or fields) other than the parent's primary key.

For instance, we could use EID as the primary key of the UT Student table, but we could use the student's SSN to link the (child) records in the Scholarship table to the corresponding (parent) record in the Student table. The SSN would be a foreign key field in the Scholarship table, but the SSN would be a simple data field, not the primary key field, in the Student table.

You might argue that this is silly... we should have used the EID for the linking. 99.9% of the time, I would agree with you.

More FAQs