Skip to content

令和5年度 ITパスポート試験 問78

This question's explanation and your answers so far.

問78
頻出度★★★

関係データベースの主キーの設定に関する記述として, 適切なものだけを全て挙げたものはどれか。 a 値が他のレコードと重複するものは主キーとして使用できない。 b インデックスとの重複設定はできない。 c 主キーの値は数値でなければならない。 d 複数のフィールドを使って主キーを構成できる。

出典 令和5年度 ITパスポート試験 問78
解説

問 78

  • Incorrectア

    Statement a is correct, but c “the value of a primary key must be a number” is wrong. A primary key can also use strings (such as employee codes or product codes); as long as it is unique, the value type is not limited to numbers. Because it includes the wrong statement c, it is inappropriate.

  • イ

    正解 The correct answer is “イ” (a, d). A primary key is a column used to uniquely identify a row (record), so as statement a says, a value that duplicates another record cannot be used as a primary key (uniqueness constraint). Also, as statement d says, when a single column cannot guarantee uniqueness, multiple fields can be combined to form the primary key, which is called a composite (compound) primary key. Therefore the correct statements are a and d, and their combination “イ” is the answer.

  • Incorrectウ

    Both b “it cannot be set in duplication with an index” and c “must be a number” are wrong. In fact, when a primary key is set, an index is automatically created to ensure uniqueness, and the two coexist. Since both statements are wrong, it is inappropriate.

  • Incorrectエ

    Statement d is correct, but b “it cannot be set in duplication with an index” is wrong. A primary key can coexist with an index; rather, specifying a primary key internally builds an index. Because it includes the wrong statement b, it is inappropriate.

ここがポイント
  • The required conditions for a primary key are uniqueness (no duplicates) and not allowing NULL; whether the value type is a number does not matter (string keys or composite keys are also allowed).
  • Multiple fields can be combined to form a primary key (composite primary key). Also, a primary key is internally accompanied by an index, so it is compatible with an index.
用語

Your answers