what is referential integrity class 10

what is referential integrity class 10

1 year ago 45
Nature

Referential integrity is a term used in database design to describe the relationship between two tables. It is a constraint on the database design that ensures that all data in a database remains consistent and up to date. It helps to prevent incorrect records from being added, deleted, or modified.

Referential integrity requires that a foreign key must have a matching primary key or it must be null. This constraint is specified between two tables (parent and child); it maintains the correspondence between rows in these tables. It means the reference from a row in one table to another table must be valid.

For example, in a database with two tables, "Customer" and "Order," the referential integrity constraint states that the customer ID (CustID) in the Order table must match a valid CustID in the Customer table. If referential integrity is not enforced, then it may lead to data inconsistency and data loss. The following are some of the reasons why this constraint is violated:

  • Primary keys are not properly enforced
  • Foreign keys are not properly enforced
  • Database design is incorrect

Referential integrity is usually enforced by creating a foreign key in one table that matches the primary key of another table. If referential integrity is not enforced, then you may encounter data redundancy and inconsistencies. Some best practices for creating referential integrity include creating primary and foreign keys for each table, ensuring that the data types are matching, and ensuring that there are no orphaned records.

Read Entire Article