Explain Referential Integrity with the help of an example.
Answers
For example, referential integrity ensures that every foreign key value in the DEPT column of the EMP table matches a primary key value in the DEPTNO column of the DEPT table. Two parent and dependent relationships exist between the DEPT and EMP tables.
hope it helps you ❤️...
Answer:
Referential integrity refers to the accuracy and consistency of data within a relationship.
Explanation:
In relationships, data is linked between two or more tables. This is achieved by having the foreign key (in the associated table) reference a primary key value (in the primary – or parent – table). Because of this, we need to ensure that data on both sides of the relationship remain intact.
So, referential integrity requires that, whenever a foreign key value is used it must reference a valid, existing primary key in the parent table.
Example
For example, if we delete row number 15 in a primary table, we need to be sure that there’s no foreign key in any related table with the value of 15. We should only be able to delete a primary key if there are no associated rows. Otherwise, we would end up with an orphaned record.