SELF-GUIDED BA PRACTICE Selected editions available · Access after confirmed paymentCheck editions ↗

Business analysis glossary

Foreign Key

What it is

A foreign key is a column that holds the primary key value of a row in another table, creating a link between them. It is how a database stores relationships such as an order belonging to a customer. Many databases can enforce this, rejecting a row whose foreign key points at nothing, which keeps the data consistent.

Why it matters

Foreign keys are what make joins possible. They also help data validation by preventing, for example, an order that points to a customer who does not exist. Reading foreign keys in a data model also tells an analyst which tables can be linked and in what direction when writing a query.

Example

The Orders table has a customer_id column. The value 87 in an order row points to the Customers row whose primary key is 87, so a query can show the customer's name beside each order. The foreign key may repeat many times in the orders table, because one customer can place many orders, which is exactly the relationship described.

CHECK BEFORE CONTINUING

Keep your work safe