Primary Key Standard¶
Purpose¶
The Primary Key Standard defines identifier rules for future database specifications.
Rules¶
| Rule | Requirement |
|---|---|
| Stable identity | Primary keys must not change after creation. |
| Opaque identifiers | IDs should not encode mutable business meaning. |
| Module ownership | Owning module defines ID semantics for its aggregate or entity. |
| Public safety | Public API identifiers must not leak internal sequencing or sensitive data. |
| References | Cross-module references use stable IDs and do not imply ownership. |
Identifier Guidance¶
- Prefer stable surrogate identifiers for aggregate roots and entities.
- Natural identifiers may be unique constraints but should not be the only identity when they can change.
- External provider identifiers are stored as provider references, not primary keys.
- Event, audit, idempotency, and outbox records require stable identifiers for traceability.
Key Flow¶
flowchart LR
Aggregate[Aggregate Root]
Id[Stable Primary Key]
Table[(Owned Table)]
Reference[Cross-Module Reference]
Aggregate --> Id
Id --> Table
Id --> Reference
Non-Goals¶
This document does not choose UUID format, sequence strategy, database type, or Java ID class implementation.