ITPEC IP April 2025 Question 26

Topic: DatabasesAlso asked in October 2019 and October 2022

By joining tables “Employees in charge”, “Regions”, and “Customers” that are managed in a relational database, the table A that is shown below is obtained. Which of the following is the table “Customers” that is used for the joining? Here, a solid underline indicates a primary key and a dotted underline indicates a foreign key.

Employees in charge

Employee codeEmployee name

Regions

Region codeRegion name

A

Customer codeCustomer nameEmployee nameRegion nameRepresentative name

Explanation

Customers with both Employee code and Region code as foreign keys — table A takes a name from each of the other two tables, so Customers must reference both.

Table A holds, per customer, Customer name and Representative name, which belong to the customer itself, plus two names that live elsewhere:

  • •Employee name is only in Employees in charge, reached through its primary key Employee code
  • •Region name is only in Regions, reached through its primary key Region code

To join a customer to its employee in charge and to its region, each customer row must carry both codes as foreign keys. Option (d) has Customer code as primary key, the customer's own attributes, and both foreign keys.

Answer (d)

Why not others:

  • •(a) — no foreign key at all, so Customers cannot be joined to either table and neither Employee name nor Region name can be obtained
  • •(b) — Employee code gives Employee name, but without Region code the Region name is missing
  • •(c) — Region code gives Region name, but without Employee code the Employee name is missing

Key rule: To join tables, the referencing table must hold the primary key of each table it draws data from as a foreign key; one foreign key per referenced table.

Databases · AI-written, may contain errors

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official IP past-paper collection or Report an issue.