Keeping Exact and Normalized Field Spellings

The same application can preserve a source field for display and derive a normalized key for comparison.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace two spellings
  2. Test key collisions
  3. Detect multiple original names that map to one key
  4. Preserve the spelling used in a diagnostic

Trace two spellings

A city field may preserve original accents and capitalization while a search field uses normalization and case folding. Both records can still distinguish an exact spelling when needed. Unicode normalization establishes canonical equivalence, while search policy controls further transformations.

Test key collisions

Two visible labels can normalize to the same key. Check whether inserting the second label should merge, reject, or store another candidate. Canonical label rules make the promised lookup behavior visible.[1]

Detect multiple original names that map to one key

If a schema normalizes field names with case folding, UserID and userid can denote the same normalized name. A single record containing both with different values should follow a collision rule instead of silently choosing whichever member was last. See collection keys and case folding.

Raw members: UserID=4, userid=8
Normalized keys: userid, userid
Under a unique-field contract, reject the collision

Preserve the spelling used in a diagnostic

A parser can normalize for comparison and retain raw spelling for error messages. For a strict exchange format, exact key matching may be the contract. Test changed case, an exact repeat and two distinct values for a normalized key.

References

  1. IETF, RFC 3629: UTF-8, a Transformation Format of ISO 10646 ↩