ITPEC IP April 2021 Question 29

Topic: Databases

In a relational database, when (A∪B) and (A∩B) are performed on table A and table B shown below, which of the following is an appropriate combination of the resulting two tables among the three tables P, Q, and R? Here, (A∪B) shows the union of A and B, and (A∩B) shows the intersection of A and B.

A

Product_codeProduct_namePrice
P001Printer120
P003PC658
P007USB hub628
P012OA chair142
P019OA desk256

B

Product_codeProduct_namePrice
P003PC658
P007USB hub628
P020USB memory30

P

Product_codeProduct_namePrice
P003PC658
P007USB hub628

Q

Product_codeProduct_namePrice
P001Printer120
P012OA chair142
P019OA desk256

R

Product_codeProduct_namePrice
P001Printer120
P003PC658
P007USB hub628
P012OA chair142
P019OA desk256
P020USB memory30
Option(A∪B)(A∩B)

Explanation

Union is R, intersection is P — a union takes every row in either table, an intersection only the rows in both.

  • •A holds P001, P003, P007, P012, P019; B holds P003, P007, P020
  • •Union: all five rows of A plus the row of B not already in A, P020, each row once: six rows, table R
  • •Intersection: the rows in both, P003 PC and P007 USB hub: table P
  • •Q (P001, P012, P019) is the difference A − B, the rows in A but not in B

Answer (c)

Why not others:

  • •(a) — swaps the two results: P is the intersection and R the union
  • •(b) — Q is the difference A − B, not the union, and R is the union, not the intersection
  • •(d) — the union is right, but Q is the difference A − B: it holds the rows A does not share with B, the opposite of the intersection

Key rule: Union, intersection and difference work on tables with the same columns; a row present in both tables appears once in the union.

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.