CompTIA Tech+ (FC0-U71)Data and Database FundamentalsMedium
An Orders table contains a column named CustomerID that stores the same values found in the CustomerID column of the Customers table, linking each order to a specific customer. What is the CustomerID column in the Orders table called?
- AComposite key
- BPrimary key
- CIndex
- DForeign key
Show answer & explanationAnswer & explanation
Correct answer: D. Foreign key
A foreign key is a column in one table that references the primary key of another table, establishing a relationship between the two tables. Here, CustomerID in Orders links back to the primary key CustomerID in Customers.
Why the other options are wrong
- A. A composite key combines multiple columns for uniqueness, not linking tables.
- B. CustomerID is the primary key in the Customers table, not in Orders.
- C. An index speeds up searches but doesn't establish table relationships.
Foreign Key
A foreign key is a column in one table that references the primary key of another table, creating a relationship between the tables.
- Links two tables together
- Value matches a primary key elsewhere
- Enables relational integrity between tables
Memory trick: Foreign Key = a Foreign visitor pointing back home (to the primary key)