Consider the two relations below. The primary keys are underlined. Identify…

2022

Consider the two relations below. The primary keys are underlined. Identify all possible foreign key(s) from the options based only on the two relations.

EMP (eid, ename, did)

DEPT (did, dname)

  1. A.

    eid

  2. B.

    did

  3. C.

    eid, did

  4. D.

    eid, did, ename

Attempted by 1233 students.

Show answer & explanation

Correct answer: B

Answer: did is the foreign key (EMP.did referencing DEPT.did).

Reasoning:

  • Identify primary keys: EMP has primary key eid; DEPT has primary key did.

  • Definition: A foreign key is an attribute in one relation that references the primary key of another relation.

  • Apply to these relations: EMP contains attribute did, and DEPT has did as its primary key, so EMP.did can reference DEPT.did and is therefore a foreign key.

  • Why other attributes are not foreign keys: eid is the primary key of EMP (not a reference to DEPT), and ename is a non-key attribute that does not match DEPT's primary key.

Conclusion: based only on the two relations, the only possible foreign key is EMP.did referencing DEPT.did.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor