Two customer systems use different identifiers for the same customer. How would you integrate them without merging the wrong records?

Instruction: Identify what a customer entity means in each system and who may approve mappings. Never treat a plausible name or email match as sufficient authority to merge business records.

Context:

Practice task

Implement resolve_customer_ids(records, approved_pairs) for this fictional customer integration. Return one result for each input record, in the original order, preserving its fields and adding status and target_id. Do not modify the input data.

Input contract

  • The entity is a customer account. All inputs have already been schema-validated, and the shown identifier fields are nonempty strings. Input records do not contain status or target_id; those fields belong to the result.
  • An identifier belongs to its tenant and source system. Reusing the same text in another tenant or source does not establish the same identity.
  • The target system is billing, one fixed namespace. Each target_id refers to an account within the same tenant. A deployment with multiple target systems would need to include the target namespace too.
  • approved_pairs is an approved mapping feed. It can contain repeated entries or conflicting approvals that need resolution. This exercise does not authenticate the caller, approve mappings or prove that a business identity is true.
  • Permitted statuses are matched, ambiguous and unresolved. Return a target only when the approved input supports one unambiguous target for the scoped source record. Do not choose between conflicting targets. An identical repeated pair does not create a new candidate.
  • Approved many-to-one relationships are allowed; do not impose target uniqueness that the customer has not requested.

Fictional inputs

records = [
    {"tenant": "north", "source": "crm", "source_id": "C7"},
    {"tenant": "south", "source": "crm", "source_id": "C7"},
    {"tenant": "north", "source": "crm", "source_id": "C8"},
    {"tenant": "north", "source": "erp", "source_id": "C7"},
]
approved_pairs = [
    {"tenant": "north", "source": "crm", "source_id": "C7", "target_id": "B12"},
    {"tenant": "north", "source": "crm", "source_id": "C8", "target_id": "B15"},
    {"tenant": "north", "source": "crm", "source_id": "C8", "target_id": "B16"},
]

Explain how you would test tenant separation, source-system separation, conflicting approvals, an identical repeated pair and an approved many-to-one relationship. State what must be checked outside this function before a mapping may authorize a cross-system write.

Updated

Official answer available

Read the opening below, then unlock the full answer and practical guidance.

I'd first agree what the customer entity means and who owns its identity mappings. A billing account and a person are different things...

Related Questions