関係データベースに関する記述中の a, b に入れる字句の適切な組合せはどれか。 関係データベースにおいて, レコード (行) を一意に識別するための情報を a と言い, 表と表を特定の b で関連付けることもできる。
平成23年度 特別試験 ITパスポート試験 問72
This question's explanation and your answers so far.
問 72
Incorrectア
The field in b is correct, but the entity in a is wrong. An entity is a person, thing, or matter that is managed in the business itself, or a concept that represents it. It is drawn as a rectangle in an E-R diagram, and in a relational database it often corresponds to one table. In other words, entity is a term at roughly the granularity of the table itself, not the information used to uniquely identify one row inside a table. In a combination question both blanks must be correct, so once a is wrong this choice can no longer be selected.
Incorrectイ
Both a and b are wrong. As explained above, the entity in a is a term for the actual object managed in the business, not the information that uniquely identifies a row (the primary key). The record in b is the row of the table itself, that is, one item of data as a unit. Tables are associated by matching the values of a common column, and a record is not the clue used for the association but the data that is retrieved as a result of it. Neither of the two blanks therefore holds.
- ウ
正解 The correct answer is ウ (a: Primary key / b: Field). First, consider blank a. The question defines it as the information used to uniquely identify a record (row), and this is exactly the definition of a primary key in a relational database. A primary key is a column (or a combination of columns) that reliably identifies one row in a table and distinguishes it from the other rows; the conditions are that its values are never duplicated (uniqueness) and that its values are never empty (NULL). Numbers or codes that are uniquely determined in the business, such as an employee number in an employee table or a product code in a product table, are chosen as the primary key. Next, consider blank b. A relational database has no special mechanism that ties tables together with lines. Instead, a column (field) common to both tables is provided, and rows whose values in that column match are joined, and in this way tables are associated with one another. For example, if an order table is given a field called customer code, its values can be matched against the customer code that is the primary key of the customer table, so the customer name and address can be retrieved for each individual order. A column provided in order to refer to the primary key of another table is called a foreign key, and a foreign key is also a kind of field (column, item). The wording “tables can be associated through a specific b” in the question refers to exactly this specific column, so b is a field. Therefore ウ, which puts a primary key in a and a field in b, is the correct combination.
Incorrectエ
The primary key in a is correct, but the record in b is wrong. A record (row) is one item of data as a unit, and fields (columns, items) lined up horizontally make up one record. What is matched when tables are associated in a relational database is the value of a specific column that exists in both tables, that is, a field (a foreign key and a primary key). Tables are not connected at the level of rows, so a record does not fit in b. Note that even if only a is right, a combination question still counts as incorrect.
- Definition of a primary key — a primary key is a column, or a combination of columns, used to uniquely identify a record (row) in a table. The conditions are that its values are not duplicated (uniqueness) and that null values (NULL) are not allowed, and items that are uniquely determined in the business, such as an employee number or a product code, are chosen.
- Associating tables, and fields and foreign keys — in a relational database, tables are associated by matching rows whose values agree in a common field (column, item). A column provided in order to refer to the primary key of another table is a foreign key. A record is the row itself, and an entity is the actual object managed in the business (a concept that roughly corresponds to a table); neither of them is the unit that serves as the clue for the association.