Primary Key
A primary key is a field, or set of fields, whose value is unique for every record in a table and never changes, so each record can be identified, linked and updated reliably.
Also called: primary key, foreign key, record ID, unique identifier, PK
A primary key is a field whose value is unique for every record in a table and never changes. It's the record's permanent ID. In a database, CRM or warehouse, the primary key is how systems find a record, link it to others and update it without creating duplicates. Most GTM sync problems trace back to keys.
How it works
A good primary key has three properties:
- Unique: no two records share it.
- Stable: it never changes for the life of the record.
- Always present: every record has one, no blanks.
Most systems generate keys for you. A CRM gives every contact and account an internal record ID. Billing tools, product databases and support desks do the same.
A foreign key is a primary key stored in another table to create a link. A contact row stores its account's ID. An opportunity stores its account ID too. Those links are what let you run a data join and report pipeline by account industry.
Across systems, you store one system's key in the other as an external ID. The CRM account holds the billing customer ID. The billing customer holds the CRM account ID. A CRM sync uses those to update the right record every time.
Sometimes no single field is unique, so a combination acts as the key, like account ID plus month in a monthly revenue table. That's called a composite key. It works, but document it clearly, because anyone joining to that table needs every part of the key to get one row back.
Example
A company syncs customers from its billing system into the CRM every night (all numbers hypothetical). The first version matches on email address.
Over six months, problems pile up:
| Issue | Records affected |
|---|---|
| Billing contact changed email, sync created a new CRM contact | 340 |
| Two customers shared one finance inbox, data overwrote each other | 45 |
| Customer used a personal email in billing, no CRM match | 210 |
The fix: add a "billing customer ID" external ID field on the CRM account, mark it unique, and match on that first. Email becomes a fallback for the first link only. After a one-time cleanup that merged 340 duplicate contacts, the nightly sync stops creating new ones. Renewal reports now tie every invoice to the right account.
By company size
Small business: you rarely think about keys. But when you import a customer list into a new tool, choose a unique column, like customer number or email, so a second import updates people instead of duplicating them.
Mid-market: keys become a design decision. Every integration should store the other system's ID. Avoid matching on names or emails for ongoing syncs. Write down which ID each system uses as part of your data model.
Enterprise: many systems, mergers and regions mean one customer can have a dozen IDs. Teams build a master ID that maps all of them, part of identity resolution and the golden record. Key mapping tables are governed and tested like any other critical data.
Primary key vs matching field
A primary key identifies a record you already know. A matching field, like email or domain, helps you guess which record an outside piece of data belongs to. Use matching fields to make the first link, then store the primary key so you never have to guess again.
Why it matters for GTM teams
Duplicates, overwritten records and broken reports usually start with a sync that matched on something unstable. We set up external ID fields before building any integration, mark them unique, and match on them first. It takes an hour at the start and saves weeks of deduplication work later. If a sync can't name the key it uses, we don't ship it.
Common mistakes
- Using email, name or domain as the ongoing key for a sync.
- Not storing the other system's ID on the CRM record.
- Allowing blank or duplicate values in a field meant to be unique.
- Changing record IDs during a migration without keeping a map from old to new.
- Building composite keys nobody documented.
- Deleting and recreating records instead of updating them, which breaks every link.
- Exposing internal IDs in public URLs or forms where people can guess other records.
FAQ
What is the difference between a primary key and a foreign key?
A primary key uniquely identifies a record in its own table, like an account ID in the accounts table. A foreign key is that same ID stored in another table to point back to it, like the account ID on a contact. Foreign keys are how tables link together.
Can email be a primary key?
It's a poor choice. People change emails, share them and have more than one, so the value isn't stable or always unique. Use a system-generated ID as the primary key and treat email as a matching field instead.
What is an external ID in a CRM?
It's a field that stores another system's primary key on a CRM record, such as the billing system's customer ID. Syncs use it to find the right record to update instead of creating a duplicate. Most CRMs let you mark such a field as unique.