Explain foreign key constraint and its importance.

Database Management System >   Database Constraints >   Constraints Introduction  

Long Question

881


Answer:

foreign key constraint allows certain attributes in one relation to refer to attributes in another relation. The relation on which foreign key constraint is defined contains the partial information. Its detailed information can be searched from another relation with a matching entry. A foreign key constraint not only controls the data that can be stored in the referencing relation but also controls the changes made to the referenced relation. For example, if the tuple for a publisher is deleted from the PUBLISHER relation, and the publisher's ID is used in the BOOK relation, the deleted publisher's ID becomes orphaned in the BOOK relation. This situation can be prevented by a foreign key constraint.

Foreign key constraint enforces referential integrity by ensuring that an attribute in a relation S whose value in each tuple either matches with the values of the primary key in another relation R or is null. For example, the foreign key attribute R_ID in the REVIEW relation must have either the same values as that of the primary key A_ID of the AUTHOR relation or must be null.


This Particular section is dedicated to Question & Answer only. If you want learn more about Database Management System. Then you can visit below links to get more depth on this subject.




Join Our telegram group to ask Questions

Click below button to join our groups.