English

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

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?
Chapter 8: Database Concepts - Exercise [Page 126]

APPEARS IN

NCERT Computer Science [English] Class 12
Chapter 8 Database Concepts
Exercise | Q 2. | Page 126
NCERT Informatics Practices [English] Class 11
Chapter 7 Database Concepts
Exercise | Q 2. | Page 138
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×