Ir para o conteúdo

Lição 17 · Master and Reference Data

Reference Data Management

Manage reference data such as country, currency and status codes with owners, versions, effective dates and mappings between systems, using SQL examples.

Reference data is the set of allowed values that classify other data: country codes, currencies, units of measure, order statuses, department codes, tax categories. It looks boring and small. Yet one changed or mismatched code can silently break reports across a whole company.

Master data or reference data?

Reference data Master data
Examples Currency codes, status codes Customers, products
Size Usually small Often large
Change Rare, controlled Frequent
Role Classifies other data Core business entities

The boundary is not always sharp. Use the labels to decide how each set is governed.

External and internal codes

External reference data comes from outside bodies, for example ISO 3166 country codes or ISO 4217 currency codes. Record which version you use and how you pick up updates, since external lists change. Check license and usage terms for lists you copy from other organizations.

Internal reference data is yours: sales regions, complaint categories, risk ratings. Someone must own each list and approve changes.

What each code list needs

TEXT
List        : order_status
Owner       : Head of Fulfillment
Steward     : Operations analyst
Source      : internal
Columns     : code, label, definition, valid_from, valid_to
Change rule : steward drafts, owner approves,
              consumers notified 2 weeks before release
Consumers   : web shop, warehouse system, reporting

The two-week notice is an example. Choose a period that gives consumers time to adapt.

Never reuse or delete a code

Old records still point to old codes. If you delete code 3, historical reports lose its meaning. If you reuse 3 for something new, history becomes false. Instead, retire a code by giving it an end date, and create a new code for new meaning.

Effective dating

Add valid_from and valid_to so you can ask what a code meant at a particular time.

SQL Look up the label that applied on a given date (SQL)

Press Run (or Ctrl + Enter) to see the result here.

Sale 4 uses a code after it was retired. That is a quality failure to investigate. Make sure date ranges for one code never overlap, or the join will return duplicate rows.

Mapping between systems

Systems often use different codes for the same idea. A crosswalk (mapping table) translates them into a shared set. Unmapped values must be visible, not silently dropped.

Python Map source statuses and report gaps

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notice the two kinds of problems: a source value with no mapping (H), and a mapping that points to a code that does not exist (VOIDED). Check for both.

Sharing reference data

Pick one authoritative place for each list and let other systems consume it through a copy, a feed or an API. Typing the same list into five systems guarantees drift. When copies must exist, reconcile them on a schedule.

Cache wisely: a system that loads codes once a year may reject a valid new code for months. Also consider language labels: keep the code stable and store translated labels separately, so reports in different languages still group correctly.

Change process

  1. Someone requests a new or changed code with a reason.
  2. The steward checks overlaps and impact, using lineage where available.
  3. The owner approves.
  4. Consumers are told the code, meaning and start date.
  5. The list is released, and mappings are updated.
  6. Monitoring watches for unmapped or invalid values.

Avoid catch-all codes such as "Other" without limits. If a large share of records is "Other", your list is missing categories or people cannot tell which one applies. Review it regularly.

A worked example: splitting a category

A fictional support team has one complaint code, DEL, for "delivery". Managers now want to separate late parcels from damaged ones. The safe change is to add two new codes, DEL_LATE and DEL_DAMAGE, with a start date, and to retire DEL from that date. Old complaints keep DEL; nobody guesses which new code they would have had.

Reports that compare years need a roll-up: all three codes belong to a parent group called delivery. The owner approves the hierarchy, consumers get notice, and a check confirms that no complaint dated after the change uses the retired code.

Hierarchies and distribution

Many code lists form hierarchies, such as city within region within country. Store the parent link explicitly and check that every child has a valid parent, with no loops. When a hierarchy changes, decide whether past reports show the old grouping or are restated with the new one. Both can be right for different questions, so label which one a report uses. Publish each list with a version or last-change date so consumers can tell whether their copy is current.

Test the consumers

Before releasing a change, test the systems that read the list. Does a report group the new code correctly? Does a form show its label? Will an older integration reject it? Check dashboards with fixed filters too, because a new code can silently fall outside every filter and make totals shrink. A simple reconciliation, in which the sum of all groups equals the overall total, catches this early.

Try it yourself

Write down a status list from a system you know, with a definition for each code. If two people would choose different codes for the same case, improve the definitions.

Check your understanding

Quick check · 3 questions

of 3 answered You scored / 3 · perfect!

  1. 1. What is the safest way to stop using a status code?

    History stays interpretable when old codes are retired rather than removed or reused.
  2. 2. Which check finds a mapping that points to a nonexistent canonical code?

    Every target should exist in the approved set.
  3. 3. Why add valid_from and valid_to to codes?

    Effective dates support correct historical reporting.

Summary

  • Reference data defines the allowed values that classify other data.
  • Give every list an owner, a change process and version information.
  • Retire codes instead of deleting or reusing them.
  • Use crosswalks and flag unmapped or invalid values.
  • Keep one authoritative source for each list.

Next: Data Classification and Access Control

Seu progresso fica salvo neste navegador. Não precisa de conta.