Skip to content

平成29年度 春期 ITパスポート試験 問90

This question's explanation and your answers so far.

問90
頻出度★★☆

関係データベースで管理している“商品”表に対して次の三つの操作a~cを行ったとき,得られる値が大きい順に操作を左から並べたものはどれか。ここで,“%”は0文字以上の任意の文字列を表すものとする。 〔操作〕 a 大盛が‘有’でかつ商品名が‘%うどん%’で選択される商品の数を求める。 b 価格が400以上かつ550以下で選択される商品の数を求める。 c 商品名が‘うどん%’で選択される商品の数を求める。 商品

商品番号商品名価格大盛
S001きつねうどん300有
S002たぬきうどん250有
S003天ぷらうどん500無
S004うどん定食550有
S005うどんすき600無
S006カレーうどん400有
出典 平成29年度 春期 ITパスポート試験 問90
解説

問 90

  • ア

    正解 Counting the number of products selected by each operation: operation a (large serving is “Yes” and the product name contains “udon”) yields the four large-serving “Yes” items S001 Kitsune Udon, S002 Tanuki Udon, S004 Udon Set Meal, and S006 Curry Udon (Tempura Udon and Udon-suki are excluded because their large serving is “No”). Operation b (price 400 or more and 550 or less) yields three items: S003 (500), S004 (550), and S006 (400). Operation c (product name starts with “udon”) yields the two items whose names begin with “udon”: S004 Udon Set Meal and S005 Udon-suki. Arranging the values in descending order gives 4>3>2, that is a, b, c, which is ア. The key point is the position of 「%」: 「%udon%」 matches any word that contains “udon” anywhere (partial match), while 「udon%」 matches only words that begin with “udon” (forward match).

  • Incorrectイ

    The order b, c, a corresponds to the case where the counts satisfy b>c>a, but in reality a=4, b=3, c=2, so a is the largest. This option places a last, so it is incorrect.

  • Incorrectウ

    The order c, a, b corresponds to the case where c is the largest, but c has only two items whose names begin with “udon”, making it the smallest. This option places c first, so it is incorrect.

  • Incorrectエ

    The order c, b, a corresponds to the case where the counts decrease monotonically as c>b>a, but c is the smallest with two items and a is the largest with four. The size relationship is reversed, so it is incorrect.

ここがポイント
  • The difference in the position of the wildcard 「%」 in a LIKE search: 「%udon%」 matches any word that contains “udon” anywhere within it (partial match), while 「udon%」 matches only words that begin with “udon” (forward/prefix match).
  • Selection in a relational database (narrowing down rows) and counting: the approach of selecting the rows that satisfy a condition and comparing their counts.
用語

Your answers