関係データベースの“商品”表から価格が100円以上の商品の行(レコード)だけを全て抽出する操作を何というか。 商品
| 商品番号 | 商品名 | 価格(円) |
|---|---|---|
| S001 | はさみ | 200 |
| S002 | 鉛筆 | 50 |
| S003 | ノート | 120 |
| S004 | 消しゴム | 80 |
| S005 | 定規 | 150 |
This question's explanation and your answers so far.
関係データベースの“商品”表から価格が100円以上の商品の行(レコード)だけを全て抽出する操作を何というか。 商品
| 商品番号 | 商品名 | 価格(円) |
|---|---|---|
| S001 | はさみ | 200 |
| S002 | 鉛筆 | 50 |
| S003 | ノート | 120 |
| S004 | 消しゴム | 80 |
| S005 | 定規 | 150 |
Join is an operation that matches two or more tables on the values of a shared item (column) and combines them into a single table. It only holds when there are multiple tables, but this question deals with just one table, the Product table, and does not match it against any other table, so it does not apply.
Projection is an operation that takes out of a table only the columns (items) you need; the direction of narrowing down is columns, not rows. For example, taking only the Product Name and Price columns out of the Product table is projection, and in principle all rows are covered (if rows with identical content appear once you look only at the extracted columns, those duplicates are merged into one). The operation in this question narrows down by a condition on rows, “the price is 100 yen or more,” so it is not projection.
正解 “Selection” is a relational operation that takes out of a table only the rows (records) that meet a condition. This question describes narrowing down by a condition on rows, “the price is 100 yen or more,” so it is selection. Applying it to the Product table in the figure, the three rows S001 Scissors 200 yen, S003 Notebook 120 yen, and S005 Ruler 150 yen remain, while S002 Pencil 50 yen and S004 Eraser 80 yen are removed. At this point all three columns — Product No., Product Name, and Price — remain exactly as they were, and only the number of rows drops from five to three. This shape of the result, “the columns stay the same and only the rows decrease,” is the mark of selection. Therefore the correct answer is ウ.
Union is a set operation that overlays two tables with the same column structure (union-compatible tables) and gathers the rows contained in either one of them into a single table. It requires two tables, and rows can only increase rather than being narrowed down by a condition, so it does not fit this question.