Question 2 of 12intermediate💡 UnderstandShort Answer3 marks

Why foreign keys are allowed to have NULL values? Explain with an example.

Correct Answer

A foreign key is allowed to have NULL values if it is not part of the primary key of the foreign table. This is because NULL is a special value used to represent data that is unknown or non-applicable to certain attributes.

For example, in a STUDENT table, if there is a foreign key referencing a GUARDIAN table, and a student's guardian information is not available or not applicable, the foreign key attribute can be set to NULL. This allows the student record to be stored even when the related guardian record is unknown or does not exist.

Exercise: EXERCISE | Q: 2 | (Page 16)
For More Understanding

Explanation

The textbook explicitly states that 'foreign key can take NULL value if it is not the part of primary key of the foreign table.' It also explains that NULL represents 'values that are unknown or non-applicable to certain attributes.' The example aligns with the GUARDIAN relation mentioned in the context, where GPhone can be NULL if data is unknown.