What is a foreign key constraint?

What is a foreign key constraint?

a) It ensures that the values in a column match values in a related table
b) It ensures that a column does not have null values
c) It guarantees the uniqueness of data in a column
d) It limits the length of data in a column

Answer:

a) It ensures that the values in a column match values in a related table

Explanation:

A foreign key constraint ensures that the values in a column (or a set of columns) correspond to valid values in another table’s primary key or unique column. It is used to maintain referential integrity between related tables in a relational database.

This constraint ensures that no invalid or orphaned records exist in the database. For example, an “orders” table might have a foreign key that references the “customers” table to ensure that each order is linked to a valid customer.

Foreign key constraints prevent inconsistency by enforcing rules about the relationships between tables.

Reference:

Database Management System MCQ (Multiple Choice Questions)

Scroll to Top