AI engineering glossary · SQL databases
What is FK (foreign key)?
Foreign key (also called FK): A column in one table whose values must match a primary key (or unique) value in another table, or be NULL. The database rejects rows that point to nothing. It expresses relationships and protects data from becoming inconsistent.
Foreign key: an example
orders.customer_id references customers.customer_id, so you cannot insert an order for customer 9999 if that customer does not exist.
Related terms
More SQL databases terms
Where you learn it
Foreign key is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.