IPA IP 2026 Question 57
A question IPA Japan published in 令和8年度 ITパスポート試験 公開問題 問57, translated into English. ITPEC is based on the same exams.
There are the “Student” table, the “Subject” table, and the “Grade” table that are managed in a relational database. When one (1) student takes multiple subjects, and a student who is not registered in the “Student” table or a subject that is not registered in the “Subject” table cannot be registered in the “Grade” table, which of the following is appropriate to be set as a foreign key? Here, an underline in a table indicates a primary key.
Student
Subject
Grade
Explanation
Student number and Subject code in the “Grade” table — each refers to the primary key of another table, so each is a foreign key.
A foreign key is a column whose values must exist in the primary key of the table it refers to (referential integrity). The rule in the question says a row of “Grade” cannot be registered for a student missing from “Student” or a subject missing from “Subject”. So:
- •Student number in “Grade” refers to Student number, the primary key of “Student”
- •Subject code in “Grade” refers to Subject code, the primary key of “Subject”
With these two foreign keys the DBMS rejects, say, a grade for student G003 or subject K004. Together the two columns are also the primary key of “Grade”, since one student takes several subjects.
Answer (c)
Why not others:
- •(a) — Student number in “Student” is the primary key being referred to; the foreign key is set only on the referring side, in “Grade”
- •(b) — names are not keys: they can repeat, and no table refers to them
- •(d) — the grade value refers to no other table
Key rule: A foreign key sits in the referring table and points to the primary key of the referred table; it is what stops rows that refer to data that does not exist.
Databases · AI-written, may contain errors
This question comes from the past questions IPA Japan publishes, translated into English by ITPEC Practice. ITPEC Practice is an independent study tool and is not affiliated with IPA or ITPEC. See the original paper (PDF) or Report an issue.