ITPEC IP April 2022 Question 27
There is the “Employee” table and the “Department” table in a relational database. The “Employee” table and the “Department” table are joined, and employees who live in prefectures different from the prefectures that their departments are located in are extracted. How many employees are extracted?
Employee
Department
Explanation
2 employees — join each employee row to its department by Department_code, then compare the two Prefecture columns.
Only H002 (Shiro Takahashi) and H003 (Ichiro Suzuki) live outside their department's prefecture.
Answer (b)
Why not others:
- •(a) 1 — stops after one mismatch; both H002 and H003 differ
- •(c) 3 — no reading of the tables gives 3: the six employees split into 4 matching and 2 different
- •(d) 4 — counts the employees whose prefecture is the same as the department's (H001, H004, H005, H006), the opposite condition
Key rule: A join pairs rows by the key value, not by position; compare other columns only after each row is paired with its own match.
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.