Skip to content

平成22年度 春期 ITパスポート試験 問93

This question's explanation and your answers so far.

問93
頻出度★★★

A社研究所の資料室では,文献の貸出管理業務を行っている。文献の貸出管理業務には,PCのデータベースソフトを活用した文献貸出管理システム(以下,文献システムという)を利用している。 文献システムのデータベース構造は,次のとおりである。 社員表

社員番号社員名メールアドレス

文献表

文献番号文献名

貸出表

文献番号文献名社員番号社員名メールアドレス貸出日返却日

保有する文献と貸出についての条件は,次のとおりである。 〔保有する文献と貸出についての条件〕 (1) 同一文献は複数保有せず,文献ごとに固有な文献番号が採番されている。 (2) 貸出期間は,貸出日を含んで最長2週間である。ここで,返却された文献をその日に違う社員に貸し出すことは可能であるが,同じ社員に対して返却した同一文献をその日のうちに貸し出すことはない。 貸出から返却までの手続は,次のとおりである。 〔貸出から返却までの手続〕 (1) 社員は借りたい文献を書庫から取り出して,資料室の担当者(以下,担当者という)に手渡し,社員番号を提示する。 (2) 担当者は文献システムを使って貸出処理を行い,社員に文献を手渡す。 (3) 文献返却時,社員は担当者に文献を返却し,担当者は文献システムを使って返却処理を行う。 文献システムにおける貸出処理と返却処理の仕様は,次のとおりである。 〔貸出処理〕 (1) 文献番号で文献表を検索し,文献名を取得する。 (2) 社員番号で社員表を検索し,社員名とメールアドレスを取得する。 (3) 貸出表のレコード(以下,貸出レコードという)を用意して,(1),(2)で取得した文献番号,文献名,社員番号,社員名,メールアドレスを設定し,貸出日に当日の日付を,返却日に空白値を設定する。 (4) (3)で設定した貸出レコードを貸出表に追加する。 〔返却処理〕 (1) 文献番号で貸出表を検索し,返却日が空白値である貸出レコードを抽出する。 (2) 抽出した貸出レコードの返却日に当日の日付を設定し,貸出表を更新する。 文献システムのデータベース構造の記述として,適切なものはどれか。

出典 平成22年度 春期 ITパスポート試験 問93
解説

問 93

  • Incorrectア

    The document number and the employee number alone do not make a row unique. Condition (1) says that only one copy of each document is held, but nothing forbids the same employee from borrowing that document again on a later day after it has been returned, so several loan records with the same document number and the same employee number but different loan dates can be created. A primary key does not allow duplicates, so this choice is inappropriate.

  • イ

    正解 The correct answer is イ. As stated in [Loan processing] (4), the loan table is a loan-history table to which one row is added every time a document is loaned out, so all we need to do is find the smallest combination of columns that can uniquely identify a single row. First, by condition (1) only one copy of each document is held, but that one copy can be loaned out any number of times after it is returned, so the document number alone produces duplicate rows. Adding the employee number does not settle it either, because the same employee may borrow the same document again on a later day. So we add the loan date, and now the second half of condition (2) — a returned document is not loaned again on the same day to the same employee — takes effect and guarantees that no two or more rows can be created with the same document number, the same employee number, and the same loan date. Therefore the primary key is the combination of document number, employee number, and loan date (a composite primary key).

  • Incorrectウ

    It is correct that the primary key of the employee table is the employee number, but if the primary key of the loan table were also the employee number, each employee could have only one loan record. In reality one employee borrows several documents and also borrows them over and over, so the employee number is duplicated within the loan table. In the loan table it is the column that serves as a foreign key referring to the employee table; it does not become the primary key.

  • Incorrectエ

    It is correct that the primary key of the document table is the document number (by condition (1) each document is unique), but it does not become the primary key of the loan table. This is because when the same document is loaned out repeatedly after being returned, many loan records with the same document number line up in the loan table. Note also that [Return processing] (1) adds the condition that the return date is a blank value on top of searching by document number, which is further evidence that the document number alone cannot pin down a row of the loan table.

ここがポイント
  • A primary key is a column (or a combination of columns) that can uniquely identify a single row in a table; duplicate values and blank values (NULL) are not allowed in it. When no single column achieves uniqueness, several columns are combined into a composite primary key.
  • For tables that accumulate a history (a loan table, an order table, a sales table, and so on), the columns that represent entities (document number, employee number) alone let the same combination appear over and over, so it is standard practice to add a date or a time to the primary key. How many columns you must add before duplicates disappear is judged from the business rules written in the question — here, condition (2), which forbids loaning the document again to the same employee on the same day.
用語

Your answers