Consider the following tables:
Project_Assigned
Reg_Id Project_No CS101 101 CS103 105 IP104 102 IP102 104
STUDENT
Roll_no Name Class Reg_ID 12 SHIVAM 12 CS101 13 SHASHANK 12 CS101 15 NISH 11 CS101 11 VIVEK 05 IP104 12 KRITI 06 IP104
Which among the following is the foreign key in table 'Project_Assigned' ?
Consider the following tables:
Project_Assigned
| Reg_Id | Project_No |
|---|---|
| CS101 | 101 |
| CS103 | 105 |
| IP104 | 102 |
| IP102 | 104 |
STUDENT
| Roll_no | Name | Class | Reg_ID |
|---|---|---|---|
| 12 | SHIVAM | 12 | CS101 |
| 13 | SHASHANK | 12 | CS101 |
| 15 | NISH | 11 | CS101 |
| 11 | VIVEK | 05 | IP104 |
| 12 | KRITI | 06 | IP104 |
Which among the following is the foreign key in table 'Project_Assigned' ?
Solution
A foreign key must refer to the primary key (or a unique key) of another table. In STUDENT, Reg_ID is not unique, since CS101 appears three times and IP104 twice. So it cannot be a primary key, and Reg_Id in Project_Assigned cannot reference it.
Project_No has no other table to refer to. Hence Project_Assigned has no foreign key.
Option 1: Reg_Id has the same name and values as Reg_ID in STUDENT, but a matching name is not enough. The referenced column must be a primary key, and Reg_ID in STUDENT is not.
Option 3: a combination of both columns has no parent table, so it cannot be a foreign key either.
Related questions:
2025: 30 May Shift 2
2026: 29 May Shift 1
2025: 14 May Shift 1
2025: 27 May Shift 2
