A retail company wants to analyze customer purchase patterns over time. The data is stored in a relational database with tables for Customers, Orders, and Products. Which database concept should be used to ensure that each order references a valid customer?
A foreign key links tables by referencing a primary key in another table, maintaining referential integrity.
Why this answer
A foreign key constraint enforces referential integrity by ensuring that every value in the 'customer_id' column of the Orders table matches a valid primary key value in the Customers table. This prevents orphaned records and guarantees that each order references an existing customer.
Exam trap
Cisco often tests the distinction between a primary key (which enforces uniqueness within a table) and a foreign key (which enforces relationships between tables), leading candidates to mistakenly choose primary key when the question asks about cross-table validation.
How to eliminate wrong answers
Option A is wrong because a view is a virtual table based on a query and does not enforce any constraints between tables. Option B is wrong because an index speeds up data retrieval but does not enforce referential integrity or validate relationships. Option C is wrong because a primary key uniquely identifies rows within its own table and cannot enforce relationships between different tables.