Advertisements
Advertisements
Question
Why foreign keys are allowed to have NULL values? Explain with an example.
Short/Brief Note
Advertisements
Solution
The value of the foreign key is derived from the Primary key of the primary table. Sometimes, we want to enter a record, which is not related. To handle this situation, it is allowed to enter a NULL value in the foreign key.
For example, Suppose a shopkeeper wants to sell a product, but the customer is not a regular customer, so his customer id does not exist. In this case, a NULL value is entered into the customerId field.
shaalaa.com
Keys in a Relational Database
Is there an error in this question or solution?
