ITPEC FE Morning April 2023 Question 27

Topic: Databases

Which of the following is an appropriate description of keys in a relational database?

Explanation

Primary key unique; foreign key matches the related primary key and may repeat — the primary key identifies each row, while a foreign key only has to point at an existing row of the related table.

  • •Primary key: each value is unique and not NULL, so it identifies exactly one row (entity integrity).
  • •Foreign key: each value must exist as a primary key value in the referenced table (referential integrity). Many rows may refer to the same parent, so values repeat, for example many employees sharing one department code. Unless declared NOT NULL it may also be NULL.

Answer (c)

Why not others:

  • •(a) — a primary key may be composite, but nothing requires it to include a foreign key column.
  • •(b) — true of the primary key only; foreign key values may be duplicated (one-to-many relationships) and may be null.
  • •(d) — reverses the roles: a primary key does not reference another table, and it is the foreign key whose values must match the related table's primary key.

Key rule: Primary key = unique and not null; foreign key = an existing primary key value of the referenced table, with duplicates allowed.

Databases · AI-written, may contain errors

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.