In a relational database, a Foreign Key is primarily used to
AUniquely identify records
BLink two related tables
CSort records
DStore encrypted data
Answer:
B. Link two related tables
Read Explanation:
- Definition: A Foreign Key is a field (or collection of fields) in one table that uniquely identifies a row of another table or the same table.
- Primary Function: Its main purpose is to establish and enforce a link between data in two tables, ensuring Referential Integrity.
- Referential Integrity: This constraint ensures that the relationship between tables remains consistent. It prevents actions that would destroy links between tables, such as deleting a record in a parent table that is still referenced by a child table.
- Key Characteristics:
- A Foreign Key value must match a value in the Primary Key column of the referenced (parent) table or be NULL.
- Unlike a Primary Key, a Foreign Key does not have to be unique; multiple rows in the child table can refer to the same parent record.
- It acts as a cross-reference between tables, facilitating the JOIN operations essential in relational database management systems (RDBMS).
- Constraints: Database administrators can define rules such as ON DELETE CASCADE or ON DELETE SET NULL to specify how the database should handle updates or deletions in the parent table to maintain database consistency.
