Databases & SQL vocabulary · Keys and Constraints

Foreign key

Meaning in databases & SQL, with examples

/ˈfɔːrən kiː/nounCore term

In databases & SQL, foreign key means: A column in one table that points to the primary key of another table, linking the two and stopping you from storing references to rows that do not exist.

In Turkish: yabancı anahtar, dış anahtar, FK

How it is used

Shortened to FK. You add or drop a foreign key, and a 'foreign key constraint fails' error means the referenced row is missing or still has child rows. Teams sometimes debate whether to enforce foreign keys in the database or only in application code.

Example sentences

  1. orders.customer_id is a foreign key to customers.id.

  2. I can't delete this customer because of a foreign key constraint on the invoices table.

Common collocations

  • add a foreign key
  • foreign key constraint
  • foreign key reference
  • drop a foreign key

This word in other fields

The same English word can have a different meaning in another field:

More terms: Keys and Constraints

Practise with graded reading

Reading at the right level is the fastest way to make new words stick. Pick free English books by level: