Advertisements
Advertisements
प्रश्न
Why foreign keys are allowed to have NULL values? Explain with an example.
टिप्पणी लिखिए
Advertisements
उत्तर
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
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
