Skip to content

令和4年度 ITパスポート試験 問65

This question's explanation and your answers so far.

問65
頻出度★★★

条件①~⑤によって,関係データベースで管理する“従業員”表と“部門”表を作成した。“従業員”表の主キーとして,最も適切なものはどれか。 〔条件〕 ① 各従業員は重複のない従業員番号を一つもつ。 ② 同姓同名の従業員がいてもよい。 ③ 各部門は重複のない部門コードを一つもつ。 ④ 一つの部門には複数名の従業員が所属する。 ⑤ 1人の従業員が所属する部門は一つだけである。 従業員

従業員番号従業員名部門コード生年月日住所

部門

部門コード部門名所在地
出典 令和4年度 ITパスポート試験 問65
解説

問 65

  • ア

    正解 A primary key is the item used to uniquely identify each row (each record) in a table of a relational database. From condition (1), the “Employee Number” is a value that each employee has exactly one of, without duplication, so no two rows share the same employee number, and this single item can reliably identify each employee. Therefore, the most appropriate primary key for the “Employee” table is “ア”, the “Employee Number”.

  • Incorrectイ

    A composite of the “Employee Number” and the “Department Code”. Since the employee number alone can already uniquely identify a row, adding the department code is unnecessary (redundant) and violates the principle that a primary key should consist of the minimum necessary items. Therefore it is not the most appropriate.

  • Incorrectウ

    From condition (2), “Employees with the same name may exist”, the value of the “Employee Name” can be duplicated. An item whose values can duplicate cannot uniquely identify a row, so it cannot serve as a primary key.

  • Incorrectエ

    From condition (4), “Multiple employees belong to one department”, the “Department Code” can take the same value across multiple employee rows. Since it cannot uniquely identify a row, it cannot serve as a primary key (it corresponds to a foreign key that references the “Department” table).

ここがポイント
  • For a primary key, choose an item that uniquely identifies each row of the table (its values do not duplicate and are always present).
  • Items that can duplicate across multiple rows (such as name or department code) cannot serve as a primary key; if there is a single unique item, there is no need to form a composite key.
用語

Your answers