CompTIA Tech+ (FC0-U71)Data and Database FundamentalsHard
A database designer is creating an OrderItems table to record each product included in each order. Neither the OrderID column nor the ProductID column alone is unique, since an order can have many products and a product can appear in many orders. What should the designer create by combining OrderID and ProductID together to uniquely identify each row?
- ACandidate key
- BSurrogate key
- CForeign key
- DComposite key
Show answer & explanationAnswer & explanation
Correct answer: D. Composite key
A composite key combines two or more columns to create a unique identifier when no single column is unique on its own. Here, combining OrderID and ProductID ensures each row in the OrderItems table can be uniquely identified.
Why the other options are wrong
- A. A candidate key is any column that could serve as a primary key, not specifically a combined one.
- B. A surrogate key is an artificial single unique column added, not a combination of existing ones.
- C. A foreign key references another table but doesn't by itself provide uniqueness combining two columns.
Composite Key
A composite key is a primary key made up of two or more columns that, together, uniquely identify each record in a table.
- Used when no single column is unique alone
- Combines two or more columns for uniqueness
- Common in many-to-many relationship tables (like OrderItems)
Memory trick: Composite Key = 'Combine' pieces to unlock uniqueness