हिंदी

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

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
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 8: Database Concepts - Exercise [पृष्ठ १२६]

APPEARS IN

एनसीईआरटी Computer Science [English] Class 12
अध्याय 8 Database Concepts
Exercise | Q 2. | पृष्ठ १२६
एनसीईआरटी Informatics Practices [English] Class 11
अध्याय 7 Database Concepts
Exercise | Q 2. | पृष्ठ १३८
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×