ITPEC IP October 2023 Question 27

Topic: Databases

From the “Product” table below, products whose supplier is “Company A” and the price is 1.40 dollars or more, and products whose supplier is “Company B” and the price is 1.70 dollars or less are extracted. Which of the following is a list of all of the obtained product names?

Product

Product codeProduct namePrice (dollars)Supplier
S001Chocolate1.50Company A
S002Cake2.60Company B
S003Sponge cake2.90Company C
S004Apple1.90Company A
S005Strawberry2.20Company B
S006Melon2.80Company C
S007Juice1.20Company A
S008Coffee1.60Company B
S009Beer2.20Company C

Explanation

Chocolate, Apple, Coffee — apply each supplier's own price condition, then take the rows that meet either one.

The condition is (supplier Company A AND price ≥ 1.40) OR (supplier Company B AND price ≤ 1.70). Company C rows never qualify.

  • •Company A: Chocolate 1.50 ≥ 1.40 yes, Apple 1.90 ≥ 1.40 yes, Juice 1.20 < 1.40 no
  • •Company B: Cake 2.60 > 1.70 no, Strawberry 2.20 > 1.70 no, Coffee 1.60 ≤ 1.70 yes

The result is Chocolate, Apple and Coffee.

Answer (c)

Why not others:

  • •(a) Cake, Strawberry, Coffee — the three Company B products regardless of price, so Cake (2.60) and Strawberry (2.20) are wrongly included and the Company A products are missed
  • •(b) Cake, Strawberry, Juice — exactly the rows that fail: each supplier's price condition reversed
  • •(d) Chocolate, Apple, Juice — the three Company A products regardless of price, so Juice (1.20) is wrongly included and Coffee is missed

Key rule: When each group has its own condition, evaluate the AND inside each group first, then join the groups with OR; boundary operators (≥, ≤) decide the edge cases.

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.