CBSE Class 11 Informatics Practices Question 53 of 85

Database Concepts — Question 16

Back to all questions
16
Question

Question 15

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

Answer

A null value can be entered in a foreign key, indicating that the records are not related. In certain situations, a foreign key may accept a NULL value if it's not a part of the primary key of the foreign table.

For example, consider an Orders table in a database. Each order may or may not be associated with a customer. If an order is placed by a guest or a new customer who hasn't been added to the system yet, the CustomerID foreign key in the Orders table can be NULL to indicate that there is no associated customer record for that order.