Skip to content

平成22年度 秋期 ITパスポート試験 問87

This question's explanation and your answers so far.

問87
頻出度★★☆

“部署”表,“都道府県”表及び“社員”表を結合して,A 表を作成した。結合した“社員”表はどれか。ここで,下線は主キーを示し,破線は外部キーを示す。 部署

部署コード部署名

都道府県

都道府県コード都道府県名

A

社員番号社員名部署名都道府県名年齢

(下線のうち実線は主キー,破線は外部キーを表す。部署表:部署コードが実線下線。都道府県表:都道府県コードが実線下線。A 表:社員番号が実線下線。選択肢は 4 肢とも 社員番号 が実線下線で,部署コード・都道府県コードは破線下線。)

  • 社員番号社員名年齢
  • 社員番号社員名年齢都道府県コード
  • 社員番号社員名年齢部署コード
  • 社員番号社員名年齢部署コード都道府県コード
出典 平成22年度 秋期 ITパスポート試験 問87
解説

問 87

  • Incorrectア

    It has only Employee number, Employee name, and Age, and not a single foreign key. It has no column to match against either the “Department” table or the “Prefecture” table, so it cannot be joined and cannot yield the Department name and Prefecture name of table A.

  • Incorrectイ

    Its only foreign key is Prefecture code, so it can be joined with the “Prefecture” table and yield Prefecture name, but it lacks the Department code that links to the “Department” table, so it cannot yield the Department name of table A.

  • Incorrectウ

    Its only foreign key is Department code, so it can be joined with the “Department” table and yield Department name, but it lacks the Prefecture code that links to the “Prefecture” table, so it cannot yield the Prefecture name of table A.

  • エ

    正解 Table A consists of five items: Employee number, Employee name, Department name, Prefecture name, and Age. Among them, Department name exists only in the “Department” table and Prefecture name only in the “Prefecture” table, so both were brought in by the join. In a relational database, to join two tables the referencing table must have a column (a foreign key) that holds the same values as the primary key of the other table. Therefore, besides Employee number (primary key), Employee name, and Age, which appear in table A unchanged, the original “Employee” table needs two foreign keys: Department code, the primary key of the “Department” table, and Prefecture code, the primary key of the “Prefecture” table. Only エ has all five of these columns, and in the figure the Department code and Prefecture code in エ are shown with dashed underlines (foreign keys), which matches the join relationship with the two tables.

ここがポイント
  • A join is an operation that matches the values of a foreign key in one table against the values of the primary key in another table and combines them into a single table. You need as many foreign keys, each corresponding to the other table's primary key, as there are tables you want to join.
  • A way to work backward from the joined table to the original table: name items (Department name, Prefecture name) are brought in from other tables via code items (Department code, Prefecture code), so the original table must still keep those foreign key columns.
用語

Your answers