Skip to content

Foreign key

A foreign key is a set of attributes in a table that refers to the primary key of another table, linking these two tables.

Core Idea

Foreign key is treated here as the recurring relational databases identity summarized by this source-grounded definition: A foreign key is a set of attributes in a table that refers to the primary key of another table, linking these two tables. A foreign key is a set of attributes in a table that refers to the primary key of another table, linking these two tables. In the context of relational databases, a foreign key is subject to an inclusion dependency constraint that the tuples consisting of the foreign key attributes in one relation, R, must also.

How would you explain it like I'm…

Names Must Be on the List

Imagine two lists. One list has all the kids in your school. The other list says which kids are on which team. A foreign key is a rule that every name on the team list has to be a real kid from the school list, so nobody can be on a team who doesn't exist.

Linking Tables Together

Databases store information in tables, like spreadsheets. Each row in a table usually has a special value, called a key, that makes it different from every other row, like a student ID. A foreign key is a column in one table that points to the key of another table, linking them together. For example, a TEAM table might list member names that must match names in a PERSON table. The rule is that every value in the foreign key must actually exist in the other table, or else be left empty.

Referential Integrity Link

In a relational database, data lives in tables made of rows and columns. A candidate key is a set of columns whose values are unique for each row, so they identify a row. A foreign key is a set of columns in one table (the child) that refers to a candidate key in another table (the parent), linking them. For instance, TEAM.MEMBER_NAME could be a foreign key referencing PERSON.PERSON_NAME, meaning every team member must be a person in the PERSON table. This rule is called referential integrity: each foreign key value must either match a key in the parent table or be empty (NULL). Database systems can enforce it automatically, for example by refusing to add a team member who isn't in PERSON. The parent table can even be the same table as the child.

 

A foreign key is a set of attributes in a table that refers to the primary key, or more generally a candidate key, of another table, linking them. In relational databases it is governed by an inclusion dependency: the tuples formed by the foreign-key attributes in relation R must also exist in some relation S, not necessarily distinct from R, where those attributes are a candidate key. A candidate key is a set of zero or more attributes whose values are guaranteed unique per tuple. For example, TEAM.MEMBER_NAME can reference PERSON.PERSON_NAME, so any member name in TEAM must exist as a person name in PERSON; every team member is a person. The table holding the foreign key is the child table; the referenced one is the parent table. Since the foreign key identifies a particular row of the referenced table, it must generally equal the candidate key of some row there or be NULL. This is the referential integrity constraint, and most DBMSs provide enforcement mechanisms.

Scope of Application

  • RESTRICT. The referential action CASCADE modifies the "behavior" of the (child) table itself where the word CASCADE is used.

  • Summary. Since the purpose of the foreign key is to identify a particular row of referenced table, it is generally required that the foreign key is equal to the candidate key in.

  • Summary. The table containing the foreign key is called the child table, and the table containing the candidate key is called the referenced or parent table.

  • Summary. In database relational modeling and implementation, a candidate key is a set of zero or more attributes, the values of which are guaranteed to be unique for each tuple (row) in.

  • Summary. The value or combination of values of candidate key attributes for any tuple cannot be duplicated for any other tuple in that relation.

Clarity

A clear use of Foreign key names the carrier, the operative relation, and the conditions under which the source treats the identity as present. The minimal definition is A foreign key is a set of attributes in a table that refers to the primary key of another table, linking these two tables.

Manages Complexity

Foreign key compresses multiple relational databases details into a stable diagnostic relation. The source shows both the central mechanism—many real world databases work around this problem by 'inactivating' rather than physically deleting master table foreign keys, or by complex update programs that modify all references to a foreign key when a change is needed.—and the practical consequence—another important limitation appears with transaction isolation: your changes to a.

Abstract Reasoning

  1. Type the carrier. Identify the relational databases entities to which the claim applies.
  2. State the relation. Use the source-grounded identity: A foreign key is a set of attributes in a table that refers to the primary key of another table, linking these two tables.
  3. Check operation and conditions. One important part of database design is making sure that relationships between real-world entities are reflected in the database by references, using foreign keys to refer from one table to another.
  4. Demand recognition evidence.

Knowledge Transfer

Within the home domain. Knowledge about Foreign key transfers literally when a new case preserves the same carrier type, relation, and recognition test. The referential action CASCADE modifies the "behavior" of the (child) table itself where the word CASCADE is used. Since the purpose of the foreign key is to identify a particular row of referenced table, it is generally required that the foreign key is equal to the candidate key in some row of the primary table, or else have no value (the NULL value. ). Beyond.

Neighborhood in Abstraction Space

Foreign key sits in a crowded region of the domain-specific corpus (35th percentile for distinctiveness): several abstractions share nearly its structure, so a description that fits it tends to fit its neighbors too.

Family — Unclustered & Miscellaneous (3155 abstractions)

Nearest neighbors

Computed from structural-signature embeddings · 2026-11-14