Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Full Foreign Key entry
How-to guide

Create a foreign key with a custom relationship field

Salesforce creates the underlying foreign key automatically when an admin adds a Lookup or Master-Detail field. The decision points are the relationship type, the parent object, and the field name.

By Dipojjal Chakrabarti · Founder & Editor, Salesforce DictionaryLast updated May 21, 2026

Salesforce creates the underlying foreign key automatically when an admin adds a Lookup or Master-Detail field. The decision points are the relationship type, the parent object, and the field name.

  1. Open the child object's Fields page

    Setup, Object Manager, pick the child object, click Fields and Relationships, then New.

  2. Pick Lookup or Master-Detail

    Lookup for soft relationships (Account-Contact-like); Master-Detail for tight ownership inheritance (Invoice-Line-Item-like).

  3. Choose the parent object

    Select the object the foreign key points to. Multiple lookups to the same parent are allowed (a deal can have a Primary Account and a Billing Account).

  4. Configure label, name, and reparenting

    Set the field label and API name. For Master-Detail, decide whether Allow Reparenting is on; that decision is hard to reverse.

  5. Set the parent-delete behavior (Lookup only)

    Pick Don't Allow Deletion, Clear the Field, or Cascade Delete. Master-Detail always cascades.

  6. Add to page layouts and FLS

    Add the field to the relevant page layouts and set field-level security on every profile that needs read or edit access.

Mandatory fields
Relationship Typerequired

Lookup or Master-Detail; decides the FK semantics.

Parent Objectrequired

The object the foreign key points to.

Field Label and API Namerequired

User-facing label and programmatic identifier.

Parent Delete Behavior (Lookup)required

Don''t Allow, Clear, or Cascade. Default is Clear.

Gotchas
  • Master-Detail relationships are hard to convert to Lookup later; the child cannot exist without a parent. Plan the relationship type carefully before populating data.
  • Cascade Delete on a Lookup is enabled only by Salesforce Support and only on certain standard objects. Custom-to-custom Lookups cap at Clear or Don''t Allow.
  • Polymorphic foreign keys cannot be queried with dot notation across all possible parents; use TYPEOF or query each parent type separately.
  • External ID fields can be set to Unique. The constraint applies even when the field is on multiple records with the same value via Person Account/Account dual storage; watch the edge cases.

See the full Foreign Key entry

Foreign Key includes the definition, worked example, deep dive, related terms, and a quiz.