Copy-Ready Template for Writing Down a Primary Key Decision

Choosing a primary key takes a moment; explaining it later takes much longer if you did not write it down. This small template records the decision in a few lines. Use it in your project notes, a school assignment or a pull request.

The template

PRIMARY KEY DECISION
Table: <name>
Each row represents: <one thing>

Options considered:
1. <option>  - pros: <...>  cons: <...>
2. <option>  - pros: <...>  cons: <...>

Chosen key: <column(s)>

Checks:
[ ] Unique in every case I can think of
[ ] Always has a value
[ ] Will not need to change
[ ] Not private or sensitive

Other rules added:
- <e.g. UNIQUE on email>

How other tables refer to it:
- <e.g. orders.customer_id -> customers.id>

Decided on: <date>   By: <name or team>

Filled-in example: a sign-up table for a coding club

PRIMARY KEY DECISION
Table: members
Each row represents: one club member

Options considered:
1. email      - pros: already unique for most people, meaningful
                cons: people change emails; siblings may share one
2. generated id - pros: never changes, small, simple to link
                cons: means nothing on its own

Chosen key: id (generated by the database)

Checks:
[x] Unique in every case I can think of
[x] Always has a value
[x] Will not need to change
[x] Not private or sensitive

Other rules added:
- UNIQUE on email, so the same email cannot sign up twice
- NOT NULL on name

How other tables refer to it:
- attendance.member_id -> members.id

Decided on: (date)   By: Learner A

Tips for each part

When to revisit the decision

If any of these happens, the written decision makes it much easier to see what to change and why.

Related pages

Run through the checklist before choosing a primary key while filling this in, and see Choosing Between Natural and Surrogate Keys for the bigger picture.

A free learning page for beginners. Practise on a test database, never on real customer data, and check the official documentation for your database version.