Primary Keys and Display Names

A primary key identifies rows uniquely and excludes null components under SQL primary-key semantics. A display name may be shared or change.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace a title change
  2. Choose the matching rule
  3. Keep existing references when the display text changes
  4. Enforce one row per declared identity

Trace a title change

An article with ID 12 can gain a revised title while records referring to ID 12 still point to the same row. Stable identifiers explain that continuity.

Choose the matching rule

If title text is unique only under a restricted policy, keep that validation separate from identity. See relational keys for how candidate keys depend on the data rules.[1][2]

Keep existing references when the display text changes

A branch office with ID 17 can change its name from Riverside to Central. Appointment rows referencing 17 can still identify the same location. If the display name were used as identity, duplicate names or a rename would complicate references. See stable record identifiers.

office: id=17, name=Riverside
appointment: office_id=17
rename office to Central
appointment continues to reference 17

Enforce one row per declared identity

A primary key is a uniqueness and presence constraint. If the product also requires display names to be unique in a region, model that separately. Test renaming one of two offices under the actual rules.

References

  1. PostgreSQL Global Development Group, Data Definition ↩
  2. PostgreSQL Global Development Group, SQL Language Tutorial ↩