Primary Key
In Salesforce database architecture, the unique Record ID (15 or 18 character) that serves as the primary key for every record in every object, ensuring each record can be uniquely identified and referenced.
Definition
In Salesforce database architecture, the unique Record ID (15 or 18 character) that serves as the primary key for every record in every object, ensuring each record can be uniquely identified and referenced.
In plain English
“A Primary Key in Salesforce is the unique Record ID (15 or 18 character) that every record has. It's the unique identifier that lets Salesforce reference records across the platform. Every record in every object has a primary key.”
Worked example
A developer at Estuary Studios writes an Apex method that takes a Salesforce Record ID as input and operates on the matching record. The Record ID is the Primary Key - a guaranteed-unique 15- or 18-character string assigned by Salesforce when the record is created, immutable for the record's lifetime. The first three characters of any Primary Key indicate the record's object type ("001" for Account, "003" for Contact, "a01" for the company's first custom object). The developer's code uses the prefix to validate the input ID is the expected object type before querying. Without a stable Primary Key, the same logic would need a composite key (object name + record name + something else) and would break the first time a record was renamed.
Why Primary Key matters
In Salesforce database architecture, the Primary Key is the unique Record ID (15 or 18 character) that serves as the primary key for every record in every object, ensuring each record can be uniquely identified and referenced. The platform automatically generates and assigns Record IDs when records are created; admins and developers don't have to think about generating them. The IDs are immutable once assigned and globally unique within an org.
Primary keys are foundational to how Salesforce works as a database. Lookups and master-detail relationships use Record IDs to link records. APIs use them for referencing specific records. Reports and queries use them for joining data. Knowing about Record IDs and their two formats (15-character case-sensitive and 18-character case-insensitive) is part of being effective with Salesforce data and integration. Mature integration practices use 18-character IDs for case-insensitivity in external systems.
How organizations use Primary Key
Uses 18-character Record IDs in all integrations to avoid case-sensitivity bugs in external systems.
Trains developers on Record ID structure and usage as foundational Salesforce knowledge.
Treats Record IDs as the canonical reference for records in all integration design.
About the Author
Dipojjal Chakrabarti is a B2C Solution Architect with 29 Salesforce certifications and over 13 years in the Salesforce ecosystem. He runs salesforcedictionary.com to help admins, developers, architects, and cert/interview candidates sharpen their fundamentals. More about Dipojjal.
Test your knowledge
Q1. What is the Primary Key in Salesforce?
Q2. What are the two ID formats?
Q3. Are Record IDs immutable?
Discussion
Loading discussion…