Concept and mechanism
Development starts by defining what each record represents. An external reference identifies an entity correctly only within its context: the same number may exist at two suppliers. External ID and Unique are distinct settings; matching does not guarantee uniqueness. Before applying a constraint, reconcile duplicates and establish whether they actually represent the same entity. Relationships also represent lifecycle decisions. Master-detail connects detail to master and supports native aggregates, but deletion dependency may conflict with independent retention. A lookup relationship likewise requires reviewing deletion behavior and necessary controls. User-facing labels do not replace the API names used by code.
Guided application
In a settlement-tracking application, first model requests, participants, and evidence. Identify which data must survive request closure or removal. Record each key’s origin and test collisions across systems. An sObject constructed in memory is not yet persisted: constructing the instance, validating fields, and performing DML are different steps. During technical review, request examples of creation, modification, duplication, and deletion. Confirm API names in metadata and document decisions affecting reports and automation. This analysis reduces late corrections during imports and avoids treating a customer’s name as technical identity.
Two providers submit reference 812 for different requests. A key including source can distinguish the entities; applying Unique only to the number would reject a legitimate request. Reconciliation should preserve decision evidence.
Common pitfalls
Confusing External ID with Unique; choosing master-detail solely to obtain a total; inferring API names from labels; treating new sObject as a save.
Related topics: Collections and choosing configuration or code · Queries, DML, and error outcomes · Triggers, limits, and asynchronous processing
Define identity and lifecycle before writing logic. Separate in-memory representation, schema, and persistence.
Reference: Differences between External ID and Unique field settings · Platform Developer guide Summer 25