関係データベースにおいて,表Aと表Bの積集合演算を実行した結果はどれか。 表A
| 品名 | 価格 |
|---|---|
| ガム | 100 |
| せんべい | 250 |
| チョコレート | 150 |
表B
| 品名 | 価格 |
|---|---|
| せんべい | 250 |
| チョコレート | 150 |
| どら焼き | 100 |
品名 価格 ガム 100 せんべい 250 チョコレート 150 どら焼き 100 品名 価格 ガム 100 せんべい 500 チョコレート 300 どら焼き 100 品名 価格 せんべい 500 チョコレート 300 品名 価格 せんべい 250 チョコレート 150
This question's explanation and your answers so far.
関係データベースにおいて,表Aと表Bの積集合演算を実行した結果はどれか。 表A
| 品名 | 価格 |
|---|---|
| ガム | 100 |
| せんべい | 250 |
| チョコレート | 150 |
表B
| 品名 | 価格 |
|---|---|
| せんべい | 250 |
| チョコレート | 150 |
| どら焼き | 100 |
| 品名 | 価格 |
|---|---|
| ガム | 100 |
| せんべい | 250 |
| チョコレート | 150 |
| どら焼き | 100 |
| 品名 | 価格 |
|---|---|
| ガム | 100 |
| せんべい | 500 |
| チョコレート | 300 |
| どら焼き | 100 |
| 品名 | 価格 |
|---|---|
| せんべい | 500 |
| チョコレート | 300 |
| 品名 | 価格 |
|---|---|
| せんべい | 250 |
| チョコレート | 150 |
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.
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.
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.