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.