pattern Commons

Share pattern

Share the full pattern page.

Private · saved on this device

Namespaced Identifiers

Carry an identifier’s assigning scope with its local value, so matching values from different systems or environments are not mistaken for the same identity.

A customer export arrives with the identifier 17. Another system also has a customer 17. A pipeline joins them, attaches the wrong invoices, and produces a record that looks internally consistent.

The missing information was the scope in which each identifier was assigned.

With Namespaced Identifiers, that scope travels with the identifier wherever ambiguity can arise. A local value becomes a qualified identity: namespace plus value. This allows independently managed systems to exchange identifiers without assuming that matching numbers mean the same thing.

Give the identifier its assigning context

A namespace defines an identifier space and its assignment rules. Within that space, a value identifies something according to those rules.

For example:

  • Namespace: crm-prod/customer
  • Local value: 17
  • Qualified identifier: the pair (crm-prod/customer, 17)

The namespace distinguishes this identifier from (billing-prod/customer, 17). It may need to capture an issuing organization, tenant, environment, entity type, or another boundary within which values are assigned independently.

The namespace must itself be unambiguous within the exchange context. Two organizations both using the label crm have only moved the collision up a level.

The pair can be stored in separate columns or represented using a defined identifier syntax. The important property is that consumers retain enough context to interpret and compare it correctly.

CRM identifier 17 retains the same namespace when received through either the CRM API or a lake export. Billing identifier 17 has a different namespace and is a distinct identifier.
The CRM API and lake export both retain the qualified pair (crm-prod/customer, 17). Billing uses (billing-prod/customer, 17). The assigning namespace includes environment and entity scope; transport paths do not change it.Scroll horizontally for readable labels; open the visual for full detail.

Example: preserve identity across a copied export

Suppose a warehouse receives these illustrative records:

Received through Identifier namespace Value
CRM API crm-prod/customer 17
Lake export crm-prod/customer 17
Billing API billing-prod/customer 17

The first two carry the same identifier. Copying the CRM record into a lake does not change who assigned its identity.

Relabeling the copied identifier as lake/customer:17 would invent a different identity unless the lake deliberately assigned a new identifier and preserved the relationship to the original.

Conversely, the Billing identifier remains distinct even though its local value matches. It might describe the same customer, or someone else. That relationship requires an authoritative cross-reference or another defensible identity-resolution process.

This distinction matters: different identifiers do not necessarily mean different entities. Namespacing prevents accidental collisions; a mapping establishes which identifiers refer to the same business object.

The delivery source is useful provenance, but it should be recorded separately from the identifier’s assigning namespace.

A published standard: FHIR’s system and value

HL7 FHIR makes the pattern explicit in its Identifier datatype. The system field identifies the namespace, while value carries the identifier within it. FHIR also provides fields for the assigning organization and the period during which the identifier is valid. HL7 FHIR R4: Identifier

Consider two illustrative hospital identifiers:

Identifier system Value
https://hospital-a.example/identifiers/patients 000731
https://hospital-b.example/identifiers/patients 000731

These are distinct identifiers, despite identical values. Neither row establishes whether they identify the same person.

A receiving organization preserving Hospital A’s identifier should retain Hospital A’s system URI. If it assigns its own local identifier, both identifiers can be retained with their respective systems.

The comparison rules also belong to the scheme. FHIR specifies case-sensitive comparison for Identifier.system and treats identifier values as case-sensitive unless the system’s rules justify otherwise. Lowercasing everything as a generic cleanup could therefore change identity. HL7 FHIR R4: Identifier Interpretation

A namespace URI provides an agreed name for the identifier system. Its usefulness depends on stable ownership and documented assignment rules, not merely on looking like a web address.

A deployed implementation: Amazon Resource Names

A cloud inventory containing only the function name daily-load cannot reliably distinguish deployments in different AWS accounts or Regions.

Amazon Resource Names, or ARNs, provide a qualified identifier. Their general structure includes a partition, service, Region, account, and resource component, although particular services omit or structure some fields differently. AWS: Identify Resources with ARNs

These illustrative Lambda ARNs distinguish identically named functions in different accounts:

arn:aws:lambda:eu-west-1:111122223333:function:daily-load
arn:aws:lambda:eu-west-1:444455556666:function:daily-load

Lambda’s API accepts function names and ARNs, with additional forms for versions and aliases. The shorter name works when the surrounding request supplies sufficient context; the full ARN carries that context explicitly for broader exchange. AWS Lambda: GetFunction

A warehouse collecting resources across accounts should preserve the qualified identifier. Stripping it down to the final name discards precisely the distinctions that make cross-account inventory possible.

Parsers must follow the service’s documented format. Treating every colon or slash as an interchangeable separator can misinterpret resource-specific structure.

What must hold for correctness

Local assignment must be reliable. A namespace cannot repair duplicate assignments within its own identifier space. The owner must define what values identify and how collisions are prevented.

The scope must be complete. A system name alone is insufficient when each tenant independently allocates customer numbers. Production and test environments may also require separate scopes when they create independent identities.

Namespace identity must persist. Rebranding an application or moving a database should not silently change the meaning of existing qualified identifiers. Stable namespace names, documented aliases, and explicit migration mappings preserve continuity.

Comparison and encoding must be defined. Leading zeros, case, Unicode, escaping, and separators can affect equality. Preserve original values and apply only the normalization permitted by the scheme.

Reuse must be understood. Some identifiers are permanent; others identify a reusable name or slot. Historical matching may require an assignment interval, generation, or immutable identifier. Namespace qualification alone does not guarantee continuity through deletion and recreation.

The URN standard illustrates stronger guarantees: its namespace rules require consistent assignment and prohibit reassigning an existing name to another resource. Those guarantees arise from the scheme’s rules, rather than from adding a prefix. IETF RFC 8141: URN Namespaces

Maintain a small registry, not a naming improvisation

Namespacing earns its upkeep when identifiers cross organizations, tenants, environments, applications, or long-lived storage boundaries.

A namespace registry can record ownership, the identified entity type, value syntax, comparison rules, reuse policy, and recognized aliases. It need not be a network service consulted for every lookup; applications can distribute stable definitions through configuration or reference data.

The costs include governance, mapping maintenance, wider stored references, validation, and migration work. Human-facing screens may need readable labels, while exports and diagnostic views retain the full identity.

Inventing a new namespace for every file, pipeline run, or transport route fragments identifiers that should remain comparable. Reusing one broad namespace for independently assigned values creates the opposite problem.

Standards have additional obligations. A string beginning with urn: is not automatically a valid URN: RFC 8141 requires an appropriate registered namespace and compliance with its assignment rules. Internal namespace keys can use a simpler managed convention when that fits their exchange scope. IETF RFC 8141: Introduction

Common mistakes and limits

A missing namespace should remain an explicit uncertainty unless trustworthy context supplies it. Assigning a convenient default can create confident but incorrect matches.

Likewise, storing a namespace column while joining, deduplicating, or caching only by local value defeats the pattern. Equality must use the qualified identity wherever the local value is ambiguous.

A UUID’s low collision probability does not explain which entity type it identifies, who assigned it, or how it relates to other identifiers. Qualification and documentation can still supply useful context.

Where an identifier already contains sufficient scope, preserve its established form. Additional wrappers should serve a clear interoperability need.

Related patterns

Composite Keys represents namespace and local value as a constrained identifying combination.

Natural Keys preserves identifiers recognized by a business or external authority.

Surrogate Keys provides an internal reference while mappings retain qualified external identities.

Bounded Contexts clarifies where an identifier’s meaning and assignment rules apply.