Skip to content

令和2年度 ITパスポート試験 問73

This question's explanation and your answers so far.

問73
頻出度★★☆

関係データベースにおいて,表Aと表Bの積集合演算を実行した結果はどれか。 表A

品名価格
ガム100
せんべい250
チョコレート150

表B

品名価格
せんべい250
チョコレート150
どら焼き100
  • 品名価格
    ガム100
    せんべい250
    チョコレート150
    どら焼き100
  • 品名価格
    ガム100
    せんべい500
    チョコレート300
    どら焼き100
  • 品名価格
    せんべい500
    チョコレート300
  • 品名価格
    せんべい250
    チョコレート150
出典 令和2年度 ITパスポート試験 問73
解説

問 73

  • Incorrectア

    This is a table that gathers all four rows Gum, Rice cracker, Chocolate, and Dorayaki, which is the result of a union that combines the rows appearing in either of the two tables. It is not the intersection that keeps only the common rows, so it is wrong.

  • Incorrectイ

    In addition to keeping all four rows, it sums up the prices of the common items, making Rice cracker 500 and Chocolate 300. A set operation only handles sets of rows and does not add prices together. Both the way rows are increased and the handling of prices are wrong.

  • Incorrectウ

    Selecting the common items (Rice cracker and Chocolate) is close to the intersection, but it sums the prices to Rice cracker 500 and Chocolate 300. In the intersection, the entire row including the price must match, and the values also stay as the originals, so it is wrong.

  • エ

    正解 The intersection (common set) operation is a set operation that, for two tables with the same column structure, extracts only the rows that exist in common in both tables. When you match Table A and Table B row by row, the only rows whose values (the combination of Item and Price) match completely are Rice cracker/250 and Chocolate/150. Gum/100, which is only in Table A, and Dorayaki/100, which is only in Table B, are not common rows, so they are not included. Therefore the result is a table made up of the two rows Rice cracker/250 and Chocolate/150, and エ is correct. Note also that the prices stay the same as their original values.

ここがポイント
  • Set operations in a relational database: the intersection keeps only the common rows of two tables with the same column structure (the union keeps all rows that are in at least one of them, and the difference keeps the rows that are in only one of them).
  • A set operation handles sets of rows (tuples); it does not add or compute numeric values such as prices, and the values of the selected rows are kept unchanged.
用語

Your answers