An order-line table stores a product code that must always match a code that exists in the product catalog table. Which database construct enforces this link between the two tables?
Show answer and explanation
Answer: C
A foreign key is a column in one table whose values must match primary key values in another table. The database enforces this link, so an order line cannot reference a product code that is missing from the catalog. This protects referential integrity across related tables. Check constraints validate values within one table, and encryption and indexing serve other purposes.
Why the other options are wrong
- A. A columnstore index speeds analytical scans and improves compression. It does not validate that a product code exists in another table, so integrity is not enforced by it.
- B. A check constraint validates values against a rule inside a single table. It cannot test whether a code appears in the catalog's key list, so it cannot enforce this link.
- D. An encryption key protects data confidentiality. It does not restrict which values may be stored in the order table, so invalid product codes could still be written.