Skip to content

平成23年度 特別試験 ITパスポート試験 問59

This question's explanation and your answers so far.

問59
頻出度★★☆

関係データベースで管理された“社員”表から選択した結果が,“高橋二郎”を含む3名だけになる条件の組合せはどれか。 社員

社員番号社員名部署名勤務地勤続年数
A0001佐藤一郎経理部東京5
A0002鈴木春子経理部東京3
A0003高橋二郎経理部大阪20
A0004田中秋子営業部名古屋5
A0005伊藤三郎営業部東京7
A0006渡辺四郎営業部東京35
A0007山本夏子人事部東京10
A0008中村冬子営業部大阪5

〔条件〕 ① 勤務地 = '東京' ② 部署名 = '営業部' ③ 勤続年数 > 10

出典 平成23年度 特別試験 ITパスポート試験 問59
解説

問 59

  • Incorrectア

    ①and②and③ keeps only the employees who satisfy all three conditions. The only one who “works in Tokyo” and “belongs to the Sales Dept.” and “has more than 10 years of service” is Watanabe Shiro (Sales Dept., Tokyo, 35 years), so the result comes to only 1 person. Takahashi Jiro is in the Accounting Dept. and works in Osaka, so he satisfies neither ① nor ②, and since the conditions are joined with and, he does not remain at all. The number falls short of 3 people and the requirement is not met either, so this is wrong.

  • イ

    正解 The correct answer is イ. This question is about the relational database operation of “selection (narrowing down rows)”: how conditions combined with and / or determine which rows remain. First, fix the employees that each condition selects on its own. ① Work Location = 'Tokyo' gives 5 people: Sato Ichiro, Suzuki Haruko, Ito Saburo, Watanabe Shiro, and Yamamoto Natsuko. ② Department = 'Sales Dept.' gives 4 people: Tanaka Akiko, Ito Saburo, Watanabe Shiro, and Nakamura Fuyuko. ③ Years of Service > 10 gives 2 people: Takahashi Jiro (20 years) and Watanabe Shiro (35 years). Here, the biggest clue is that the required result must include “Takahashi Jiro”. Takahashi Jiro is in the Accounting Dept. and works in Osaka, so he satisfies neither ① nor ②; he satisfies only ③. Therefore, for Takahashi Jiro to remain, ③ must be joined with or so that it holds on its own, and at this point ア and ウ, which join ③ with and, can be dropped from the candidates. Of the remaining イ and エ, evaluate イ, (①and②)or③: ①and② means “works in Tokyo and belongs to the Sales Dept.”, which is Ito Saburo and Watanabe Shiro, 2 people; adding with or the Takahashi Jiro and Watanabe Shiro of ③, and merging the duplicated Watanabe Shiro, gives Takahashi Jiro, Ito Saburo, and Watanabe Shiro, 3 people. It includes Takahashi Jiro and comes to exactly 3 people, meeting the requirement with nothing missing and nothing extra. Also, and keeps only the rows that satisfy both sides, so the result narrows, while or keeps the rows that satisfy either side, so the result widens. Once you grasp this property and note that the parentheses make and be evaluated first, you can confirm that イ is the answer.

  • Incorrectウ

    ①or(②and③) first evaluates ②and③ inside the parentheses, obtaining the 1 person “in the Sales Dept. and with more than 10 years of service”, Watanabe Shiro, and then adds with or the 5 people of ① who “work in Tokyo” (Sato Ichiro, Suzuki Haruko, Ito Saburo, Watanabe Shiro, and Yamamoto Natsuko). Watanabe Shiro is already included, so the result stays as the 5 people working in Tokyo. Takahashi Jiro works in Osaka, and because ③ is bundled with ② by and it cannot take effect on its own, so he is not selected. The number is also 5 people rather than 3, so this is wrong.

  • Incorrectエ

    ①or②or③ is the loosest combination, in which a row remains as long as it satisfies even one of the three conditions, so the result spreads out to the maximum. Putting together all of the 5 people working in Tokyo, the 4 people in the Sales Dept., and the 2 people with more than 10 years of service, Tanaka Akiko (Sales Dept.) who works in Nagoya, Nakamura Fuyuko (Sales Dept.) who works in Osaka, and Takahashi Jiro (20 years of service) who works in Osaka are all included, and all 8 people in the Employee table end up matching. Takahashi Jiro is included, but the requirement of exactly 3 people is not met, so this is wrong.

ここがポイント
  • The relational operation “selection” and the and / or of conditions — selection is the operation of taking out from a table only the rows that match a condition. and (logical AND) keeps only the rows that satisfy both sides, so the result narrows; or (logical OR) keeps the rows that satisfy either side, so the result widens. When parentheses are present, what is inside them is evaluated first.
  • A way of solving by working backwards from the row that must appear in the result — in a question that specifies “includes Takahashi Jiro”, it is a good idea to first check which conditions that row satisfies. Takahashi Jiro satisfies only ③ (Years of Service > 10), so only a combination in which ③ is joined with or and takes effect on its own can be the answer, and options that join ③ with and can be ruled out without calculating anything.
用語

Your answers