← All Kits · SQL CASE Expression · SQL Kit
Entity Resolution: One Real Thing, Many Messy Names
Count the distinct artists in Billboard's public chart history and you get a number that is simply wrong — because "Elvis Presley", "Elvis Presley With The Jordanaires", and five other credit strings are all the same man. One real-world entity, seven database strings. Every dataset that touches human-entered names has this disease: customers who signed up twice, "IBM" vs "I.B.M." vs "International Business Machines", the same supplier in two systems with two spellings. The discipline of curing it is called entity resolution (also record linkage when matching across two datasets, or deduplication within one), and it's among the most common real-world analyst tasks that beginner courses never teach. This guide teaches it the way it actually goes: on real, uncooperative data, mistakes included.
- The vocabulary map
- Step 1: measure the fragmentation before fixing anything
- Step 2: build rules by preview, catch, fix, re-check
- Step 3: know when NOT to merge (the false-positive check)
- Step 4: match rates — the honesty number
- Step 5: clerical review — reading the leftovers
- The principles, distilled
- References
The vocabulary map
| Term | Meaning |
|---|---|
| Entity | The real-world thing: one artist, one customer, one company |
| Entity resolution | Figuring out which records refer to the same entity |
| Record linkage | The same problem across two datasets ("is row 5 in file A the same person as row 90 in file B?") — formalized by Fellegi & Sunter (1969) |
| Deduplication | The same problem inside one dataset |
| Normalization / standardization | Transforming values toward a canonical form (lowercasing, trimming, cutting suffixes) so equal things become equal strings |
| Match key | The cleaned column(s) you actually join on |
| Match rate | The share of records that successfully found their counterpart — the number that keeps the whole exercise honest |
| Clerical review | Human eyes on the records the rules couldn't decide — a formal stage of the classic framework, not an admission of failure |
Step 1: measure the fragmentation before fixing anything
The worked example running through this guide: Billboard Hot 100 history, 1958 to present, where the goal is one clean row per artist. The amateur move is diving into fixes. The professional move is sizing the problem first:
- Depth: pulling every credit containing "Elvis Presley" found seven distinct strings for one man, with his catalog split nearly in half between "Elvis Presley" (50 songs) and "Elvis Presley With The Jordanaires" (53). Counting by raw credit undercounts the King by half.
- Breadth: counting joiner patterns across all 11,275 distinct credits: " Featuring " appears in 2,662, " With " in 244, " & " in 1,994 — up to 43% of all credits carry a joiner. This is not edge-case cleanup; it's a core design requirement.
Those two numbers decided everything downstream: fragmentation this widespread means normalization rules are mandatory, and any rule will touch thousands of rows, so the rules must be tested, not trusted.
Step 2: build rules by preview, catch, fix, re-check
The extraction rule — "the primary artist is the text before the joiner word" — was built as a CASE ladder and proven on real rows before anything was built from it. The iteration is the lesson:
- First preview caught "2Pac Duet With Mopreme" → "2Pac Duet": the credit joins with " Duet With ", the rule only knew " With ". A fake artist, invented by a cleaning rule.
- The fix added a " Duet With " rung ABOVE " With " — in a CASE ladder, specific patterns must sit above the general patterns they contain. Re-checking the exact rows the fix targeted caught "Patti Austin A Duet With James Ingram" → "Patti Austin A". One more rung: " A Duet With ".
- Re-check again: clean. The ladder was frozen and used to build the artist table: 11,275 raw credits collapsed to 8,896 artists.
Nobody writes the complete rule on the first try, and the data will not send an error message when your rule invents "2Pac Duet." Preview on real rows, catch, add a rung, re-check the exact targets — until the exceptions stop. (The full ladder, with every defect it caught, is walked through in the CASE expression guide.)
Step 3: know when NOT to merge (the false-positive check)
The "&" joiner appeared in 1,994 credits — should it split too? Reading the highest-volume "&" credits before writing the rule settled it: the list is dominated by permanent duos and bands — Kool & The Gang, Earth, Wind & Fire, Simon & Garfunkel — with only a few temporary collaborations. Splitting on "&" would shred real bands into artists that don't exist. Decision: don't split. The cost (a duo member's solo career never merges with their duo work) was written down as a limitation instead.
This is the half of entity resolution beginners miss: over-merging is as destructive as under-merging, and the mature output is sometimes a documented refusal. Related discoveries in the same project made the point again at other scales: the same duo credited as "¥$: Ye & Ty Dolla $ign" AND "¥$: Kanye West & Ty Dolla $ign" (aliases — no rule can know those are one act without a lookup dictionary), and three artists split purely by capitalization ("Tyler, The Creator" vs "Tyler, the Creator"), cured by lowercased match keys.
Step 4: match rates — the honesty number
The project's payoff required linking the chart data to a second dataset (listener statistics from a music API) by artist + title text — classic record linkage. The discipline: measure the match rate before and after every cleaning rule.
- Baseline, case-insensitive matching only: 31.2% of tracks found their chart counterpart.
- After one targeted rule — trimming " (feat. …)" / " (with …)" credit tails that the API's titles carry and chart titles don't: 37.0%. The rule recovered 763 real matches.
- Blanket-stripping ALL parentheses would have scored higher still — and been wrong: an eyeball check first showed parentheses are often part of the song's real name ("Single Ladies (Put a Ring on It)"). Same lesson as "&": read before you rule.
Note what the match rate is for. In this project it was never supposed to reach 100% — unmatched tracks were the whole point (songs that never charted). The rate's job is separating signal from defect: rules should recover the spelling casualties without inventing false matches, and the rate quantifies each rule's contribution so the cleaning stops when improvements do.
Step 5: clerical review — reading the leftovers
The classic record-linkage framework classifies candidate pairs three ways: confident matches, confident non-matches, and a middle zone that goes to human review (Fellegi & Sunter, 1969). In everyday analyst practice that third bucket is simpler and cheaper: after the rules run, read the unmatched rows — sorted so the most consequential come first. If the top of the unmatched list is full of records that obviously SHOULD have matched, your rules have a gap; if it reads as genuinely unmatched, the linkage is done and the residual becomes a documented, quantified limitation. Ten minutes of reading, and it's the difference between "the join ran" and "the join is right."
The principles, distilled
| Principle | One-line version |
|---|---|
| Measure first | Size the fragmentation (depth on one entity, breadth across the table) before writing any rule. |
| Preview every rule | Show original and transformed side by side on real rows; read them. |
| Specific above general | In any rule ladder, the narrow pattern outranks the broad pattern it contains. |
| Check false positives | Before merging or splitting, read the rows where a wrong rule does the most damage. |
| Sometimes: don't merge | Over-merging destroys real entities. A documented refusal is a valid output. |
| Match keys, stored and indexed | Compute normalized keys once into real columns; join on those, not on function-wrapped originals. |
| Match rate per rule | Measure before and after each rule; stop when the rate stops moving for honest reasons. |
| Clerical review | Read the leftovers before declaring victory. |
| Log everything | Every decision (including refusals) goes in the data-quality record and the limitations section. |
The Steam Hidden Gems and Streaming Hidden Gems projects carry these habits through full analyses you can read, and the free SQL Kit teaches the LIKE, CASE, LOWER, and JOIN moves every step above uses.
Open the SQL Kit →References
- Fellegi, I. P., & Sunter, A. B. (1969). A theory for record linkage. Journal of the American Statistical Association, 64(328), 1183–1210. doi:10.1080/01621459.1969.10501049
- Wang, R. Y., & Strong, D. M. (1996). Beyond accuracy: What data quality means to data consumers. Journal of Management Information Systems, 12(4), 5–33. (The fitness-for-use standard the merge/don't-merge tradeoffs answer to.)