IPA IP 2023 Question 78
A question IPA Japan published in 令和5年度 ITパスポート試験 公開問題 問78, translated into English. ITPEC is based on the same exams.
Which of the following lists all and only the appropriate descriptions concerning the setting of a primary key in a relational database?
Explanation
Descriptions A and D — a primary key must identify every record uniquely, and it may be made of more than one field.
Each description in turn:
- •A, correct — the primary key is what tells one record from another, so a field whose values repeat across records cannot be the primary key (nor can one that may be empty, NULL)
- •B, wrong — a primary key and an index can be set on the same field; most database systems in fact create an index on the primary key automatically to enforce its uniqueness and speed up searches by it
- •C, wrong — the data type does not matter, only uniqueness: codes such as
G001or text such as an e-mail address serve as well as numbers - •D, correct — when no single field is unique, a combination can be: in a grade table, student number plus subject code identifies a row (a composite key)
Answer (b)
Why not others:
- •(a) — includes C, but a primary key need not be numeric
- •(c) — B and C are both wrong, and the two correct descriptions are left out
- •(d) — includes B, but a primary key is normally indexed, not barred from an index
Key rule: A primary key needs unique, non-null values; its data type is free, and it may combine several fields into a composite key.
Databases · AI-written, may contain errors
This question comes from the past questions IPA Japan publishes, translated into English by ITPEC Practice. ITPEC Practice is an independent study tool and is not affiliated with IPA or ITPEC. See the original paper (PDF) or Report an issue.