What is a foreign key constraint used for in a relational database?

What is a foreign key constraint used for in a relational database?

a) To enforce referential integrity between two tables
b) To prevent null values in a column
c) To ensure unique values in a column
d) To improve the performance of SELECT queries

Answer:

a) To enforce referential integrity between two tables

Explanation:

A foreign key constraint is used to enforce referential integrity between two tables by ensuring that the value in one table (the foreign key) corresponds to a valid value in another table (the primary key).

This constraint ensures that relationships between tables are maintained, preventing orphaned records and ensuring consistency in the data.

Foreign key constraints are essential for maintaining logical relationships between tables, such as linking customer records to their corresponding orders in a sales database.

Reference:

Database Management System MCQ (Multiple Choice Questions)

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top