What is referential integrity in a database?
a) Ensuring that foreign key values match primary key values
b) Ensuring that all tables are normalized
c) Ensuring that data types match between tables
d) Ensuring that queries run efficiently
Answer:
a) Ensuring that foreign key values match primary key values
Explanation:
Referential integrity is a database concept that ensures that relationships between tables remain consistent. It is maintained by enforcing that any foreign key value must match an existing primary key value in the referenced table.
This prevents orphaned records and ensures that the data across related tables is valid. For example, in an order management system, referential integrity ensures that every order is linked to a valid customer in the customer table.
Maintaining referential integrity is crucial for preserving data consistency and preventing data anomalies in relational databases.