Prepare for the A Level Computer Science OCR Exam with engaging quizzes, detailed explanations, and effective study tips. Maximize your readiness and boost your confidence for exam day!

Practice this question and more.


What is a key function of a foreign key in a relational database?

  1. To uniquely identify records within one table

  2. To establish a relationship between two tables

  3. To limit the number of records

  4. To serve as a temporary identifier

The correct answer is: To establish a relationship between two tables

A foreign key plays a crucial role in establishing relationships between two tables in a relational database. This functionality allows one table to reference the primary key of another table, which creates a link between them. Through this relationship, the foreign key ensures data integrity and enforces referential integrity, meaning that the data in the foreign key field must either match a primary key value in the referenced table or be null. This is fundamental in maintaining the logical connections between entities within a database, thereby facilitating complex queries and data management. The other options do not accurately describe the function of a foreign key. For instance, while uniquely identifying records is a responsibility of a primary key, the foreign key's primary purpose is to link tables rather than serve this distinct function. Similarly, limiting the number of records is not a characteristic of foreign keys; rather, it relates to data constraints and how records are managed overall in a database. A temporary identifier does not match the function of a foreign key since its purpose is to maintain a persistent reference to another table's primary key, rather than serving as a short-term label for records.