Skip to content

平成30年度 秋期 ITパスポート試験 問73

This question's explanation and your answers so far.

問73
頻出度★★★

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

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

問 73

  • Incorrectア

    A uniqueness constraint (unique constraint) is a property of a primary key or unique key, which does not allow duplicate values. The property that a foreign key has is a “referential integrity constraint,” meaning that only values existing in the referenced table can be set; it is not a uniqueness constraint.

  • Incorrectイ

    Duplicate values can be set in a field on which a foreign key is defined. For example, if “department code” is made a foreign key, the same value appears repeatedly because multiple employees belong to the same department. It is the primary key or unique key that does not allow duplicates, not the foreign key.

  • Incorrectウ

    Multiple foreign keys can be defined in a single table. For example, when an “order table” references both a “customer table” and a “product table,” it has two foreign keys: the customer code and the product code. There is no restriction limiting the number of foreign keys to “at most one.”

  • エ

    正解 A foreign key can be defined by grouping multiple fields together into a single foreign key. This is because when the primary key of the referenced table is a “composite key (concatenated key)” made up of multiple fields, the foreign key on the referencing side must also be defined using the same combination of multiple fields. Therefore, “エ”, which states that multiple fields can be grouped together and defined as a single foreign key, is appropriate.

ここがポイント
  • A foreign key references the primary key of another table and is an item for maintaining “referential integrity,” meaning only values existing in the referenced side can be set. It allows duplicate values, multiple foreign keys can be defined in a single table, and a composite foreign key grouping multiple fields together can also be defined.
  • “Not allowing duplicates (uniqueness constraint)” is a property of the primary key and unique key, not of the foreign key. Distinguishing the difference in roles between the two is the point of this question.
用語

Your answers