The Complete Mapping Stage: Sixteen Decisions, Sixteen Diagrams, One Running Example: How Raw Records Become One Clean, Searchable Shape.

Sixteen decisions, sixteen diagrams, one running example — how raw records become one clean, searchable shape. By ingoampt.

Sixteen decisions, sixteen diagrams, one running example — how raw records become one clean, searchable shape. By ingoampt.

The Complete Mapping Stage: Every Decision, Visualized

The Complete Mapping Stage: Every Decision, Visualized

Sixteen decisions, sixteen diagrams, one running example — how raw records become one clean, searchable shape. By ingoampt.

This is the full, detailed walkthrough of the mapping stage — the process that turns preserved raw records into one clean, shared shape a search system can actually use. Every decision below gets its own small example and its own diagram, so you can see the shape of the problem, not just read about it.

One running example

We use one small, invented reference-library archive throughout — similar in spirit to a service like PubMed, simplified so the ideas stay clear.

1Design the shared shape first

Before writing any mapping code, decide the destination: a small set of tables whose columns mean the same thing regardless of which record type or source they came from.

clean_records clean_contributors clean_identifiers clean_links clean_relations clean_notes clean_provenance Designed once, filled in mechanically afterward — like choosing spreadsheet columns before typing any rows.
Diagram 1: the seven-table shape, agreed before any record is mapped.
WarningSkipping this and designing columns as you go usually means redesigning them halfway through — far costlier than getting them right first.

2Build the first record type

Pick the single most common type and get it fully working, tested, before touching any other type.

<article id="10.1234/ex.2025.041">
  <author>Maria Chen</author>
  <title>Adaptive Filtering for Noisy Sensor Streams</title>
  <journal>Journal of Applied Signal Processing</journal>
  <year>2025</year>
</article>
raw XML fields author = Maria Chen title = Adaptive Filtering… journal = J. Applied Signal Proc. one clean row title: Adaptive Filtering… venue: J. Applied Signal Proc. author[1]: Maria Chen
Diagram 2: the first working slice — one type, four fields, end to end.

3Prove safety before adding more

Before expanding, prove the machinery is safe: a crash mid-write leaves nothing behind, and mapping the same record twice never creates duplicates.

A crash while writing record #2 record #1 ✓ SAVEPOINT setbefore #2 record #2 (title ok,then crash) ✗ ROLLBACK TO SAVEPOINT → record #1 ✓ record #2’s half-written rows are gone
Diagram 3: a per-record SAVEPOINT means a crash never leaves a broken record.

The red/green cycle used for every new rule

REDwrite a failing test GREENmake it pass REFACTORtidy up
Diagram 4: this loop repeats before every one of the remaining thirteen decisions.

4Add a second type — and see what changes

Choose a second type deliberately close to the first, so you can see exactly what has to change: a conference paper, whose venue comes from a different source field.

article.journal = “J. Applied Signal Proc.” inproceedings.booktitle = “Proc. of Example Conf.” clean_records.venue
Diagram 5: two different source field names, one shared clean column.

Key ideaThe reader of the clean table never needs to know whether the venue originally said journal or booktitle. That difference is absorbed here, once.

5Books and chapters — editors, not just authors

Books introduce a real new idea: some are credited to editors rather than a single author.

<book id="books/ex/Handbook25">
  <editor>Priya Anand</editor>
  <editor>Tom Field</editor>
  <publisher>Example Academic Press</publisher>
  <series>Systems Engineering Series</series>
</book>
clean_contributors role=editor pos=1 Priya Anand role=editor pos=2 Tom Field never do this role=author pos=1 Priya Anand (misrepresents authorship credit)
Diagram 6: editors stay labelled as editors — the role is never silently relabelled.

6Theses — an institution, not a venue

A thesis was submitted to a university, not published in competition with other work. Forcing the university name into venue would misrepresent what kind of document it is.

school = “Example Technical University” clean_records.institution ✓ clean_records.venue ✗
Diagram 7: a university name goes to its own column, never disguised as a venue.

7Containers and datasets — not everything is an article

A proceedings volume holds many papers; it is not itself a paper. A dataset entry describes data, not an argument. Both need their own candidate_role so they never crowd out real publications in search.

role = publication journal article conference paper book / chapter thesis role = container proceedings volume (holds papers, is not one itself) role = dataset released data, not a written argument
Diagram 8: three separate search lanes, so a search for papers only searches papers.

8Fine bibliographic detail

Once the basic shape works everywhere, add finer citation detail: volume, issue, page range — copied exactly, never reformatted.

volume: 42 issue: 7 pages: 123-145 exact text in, exact text out — no reordering, no reformatting
Diagram 9: three small fields, copied without interpretation.

9Links and a conservative identifier

An electronic link sometimes contains, in disguise, a resolvable identifier. Recognise it — but only on a complete, unambiguous match.

ee = https://doi.org/10.1234/ex.2025.041 clean_links (unchanged, kept) clean_identifiers (doi extracted, extra)
Diagram 10: one link produces two things — kept as a link, and, only on an exact match, also captured as an identifier.

10A validated identifier — ISBNs

ISBNs carry a built-in checksum, so the mapping stage can validate, not just copy.

978-3-16-148410-0 checksum valid → trusted exact match checksum invalid → stored, flagged unverified
Diagram 11: the same original text is preserved either way; only the trust level differs.

11Relations between records

Some fields point to a different record entirely — a cross-reference from a paper to the proceedings volume it belongs to.

conference paper #701 crossref proceedings volume #650
Diagram 12: a labelled pointer, stored as-is; resolving it is a later, separate step.

12The remaining link types

A few smaller link kinds round out the picture: archive discs, streamed recordings, and links attached to the publisher or series name.

archive disc recording publisher link series link clean_links (same table, more rows)
Diagram 13: small in volume, cheap to add once the general table already exists.

13Identity records — not everything is a publication

Some records exist only to identify a person — a homepage entry, not a paper. Treated naively, the name field would falsely become “authorship.”

<www id="homepages/44/Chen-M">
  <author>Maria Chen</author>
  <title>Home Page</title>
</www>
www homepage record “Chen authored a paper” ✗ false role=identity, no contributor row ✓
Diagram 14: the dangerous path avoided, the honest path taken.

14Notes — one field, many meanings

The same field name carries wildly different meanings depending on context — an affiliation here, a publication status there.

“University of Example” “Invited Paper” “Reprint from 1990” clean_notesexact text, order, and hints — not forced into one meaning
Diagram 15: three genuinely different meanings, stored honestly rather than forced into one column.

15Fields that stay source-only, on purpose

Some fields are too ambiguous to map safely yet. The correct move is to wait, not guess.

month = “February” “2025-02-01”? invents a day nobody supplied ✗ stays in the raw copy ✓ until a real date policy exists
Diagram 16: “not yet mapped” is a deliberate, honest choice — not a gap left by accident.

16Everything, in one picture

#DecisionWhat it adds
1Shared shapeSeven destination tables, agreed in advance
2First typeTitle, year, authors, venue — one type, working end to end
3Prove safetyRollback and duplicate protection, tested before scaling up
4Second typeVenue from a different source field, same clean column
5Books/chaptersEditors kept distinct from authors; publisher, series
6ThesesA separate institution column, never disguised as venue
7Containers/datasetsCandidate roles beyond “publication”
8Fine detailVolume, issue, pages — copied exactly
9Links + identifiersDOI recognised only on an exact, complete match
10Validated identifiersISBN checksum validation
11RelationsPointers to other records, resolved later
12Remaining linksArchive, recording, publisher/series links
13Identity recordsHomepages kept honest, excluded from publication search
14NotesStructured but uninterpreted free text
15Source-only fieldsAmbiguous fields left unmapped until a safe rule exists
16ResultOne clean layer, ready for indexing and search
raw copy all 16 decisions index search + rank measure
Diagram 17: sixteen careful decisions produce the clean layer the search stage depends on.

FAQ

Why so many small decisions instead of one big function?
Each is independently testable and independently risky. A single giant function hides which rule broke when something goes wrong; sixteen small ones make every failure traceable to one exact cause.
Why do containers and datasets get their own role instead of being excluded?
They are legitimate, useful records — just not publications. A separate role means they stay searchable on purpose, without contaminating ordinary publication search.
Isn’t leaving fields “source-only” just delaying work?
It delays work you are not yet ready to do safely. A wrong guess baked into millions of records costs far more to fix than a field that simply waits for its proper rule.
Why validate ISBNs instead of just trusting the source?
A checksum is a free, mechanical way to know whether a value is trustworthy before relying on it for an exact match.
What’s the payoff for all sixteen steps?
A clean layer where every column means exactly one thing, every value is provably faithful, and every missing value is honestly missing — the foundation a fast, trustworthy search system needs.

This article was written by ingoampt.

© ingoampt — practical guides to building trustworthy data systems.

Leave a reply

Your email address will not be published. Required fields are marked *