Skip to content

平成21年度 秋期 ITパスポート試験 問84

This question's explanation and your answers so far.

問84
頻出度★★★

関係データベースの主キーに関する記述のうち, 適切なものはどれか。

出典 平成21年度 秋期 ITパスポート試験 問84
解説

問 84

  • Incorrectア

    Tables are related to each other when one table references another table's primary key as a foreign key. The referencing column does not have to be a primary key, and the referenced side is not limited to a primary key either (some implementations allow referencing a column with a uniqueness constraint). So asserting that tables can be related only by the primary key is wrong.

  • Incorrectイ

    A primary key is subject to the entity integrity constraint, so it cannot take NULL as a value. NULL means the value is unknown or undetermined, and allowing it would make it impossible to identify a row uniquely. In a composite primary key, none of the constituent items may be NULL either.

  • Incorrectウ

    A primary key carries a uniqueness constraint, so within the same table no two rows may hold the same value. If duplicate values were allowed, that value could not pin down a row and the primary key would not fulfil its role. It is ordinary items other than the primary key that may contain duplicates.

  • エ

    正解 The requirement for a primary key is that it can uniquely identify a row in a table, so when a single item cannot guarantee uniqueness, several items may be combined to form the primary key. This is called a composite (concatenated) primary key. For example, in an Order Details table an order number alone cannot pin down a row, but combining the order number with the detail line number identifies the row uniquely. Therefore エ, which says that within a single table multiple items may be combined to serve as the primary key, is appropriate.

ここがポイント
  • A primary key has two essential requirements: uniqueness (no two rows share the same value) and NOT NULL (a value must always exist). These two points alone immediately rule out イ and ウ.
  • When a single item cannot guarantee uniqueness, a composite (concatenated) primary key made of several items can be used. Relationships between tables are established through the correspondence of a primary key and a foreign key.
用語

Your answers