Chart RS-26 · FN-02 2026-11-17 · 3 min read
Chart lighting

Field note FN-02

Codes are not identities: cleaning aviation data for a flight log

Airline codes get reused, airports get renamed, a registration has five spellings. How SkyJourney decides which source to believe.

Project · SkyJourney →

A flight log looks like a simple table: date, flight number, from, to, aircraft. Every one of those columns comes from someone else’s data, and the sources don’t agree with each other, or sometimes with themselves.

SkyJourney’s reference data starts from three community datasets of airports and airlines. Flight-data APIs supply schedules and status, and free ADS-B networks supply tail numbers and flight paths. On top of that, users import their history from other apps, from TripIt, and from forwarded emails.

I don’t run a grand merge that reconciles all of that field by field. What I have instead is a set of rules at the point where data is used, each written after a specific thing went wrong. This note is those rules.

An IATA code is not an airline

The airlines table started out treating the two-letter IATA code as unique. It seemed obviously right, and it’s wrong. When an airline disappears, its code is reassigned, and the datasets keep both. By one count, 79 IATA codes belong to more than one airline.

I had already removed that rule in production by hand, and the proper change came later so the test database would match. That’s a solo-developer confession in one line.

Where both codes are given, the three-letter ICAO one wins, because it is reassigned far less often. Where only a shared IATA code is available, the airline name settles it, and if that doesn’t, the newest record does.

Ask the model, then check its answer

When an import gives only an airline name, SkyJourney tries an exact name match, then the flight-number prefix, then an AI model on Cloudflare Workers, then a fuzzy match. The model is the step I trust least. Asked for Ryanair, it has answered RY, which is Rainbow Air Canada. So its answer is only accepted if that airline shares the name’s first word.

Airports change their codes

Palm Beach became DJT. Astana went from TSE to NQZ. An export from another app might use either generation, and so might the airports dataset, so a small list of aliases works in both directions, each with its source noted.

It covers same-airport changes only. Berlin Schönefeld (SXF) is not an alias of Brandenburg (BER). A flight to SXF in 2015 landed at a different airport, so SXF keeps its own record. A logbook is history, and folding the old airport into the new one would quietly move people’s past flights.

New airports are the opposite problem. Navi Mumbai, Western Sydney and a few others weren’t in the dataset yet. I found out because imports failed on them, and at the time those flights were dropped without the user being told. Missing reference data showing up as one user’s error at a time is still the weakest part of this.

One airframe, five spellings

A registration can arrive as B-HLV, BHLV, G- UZLF or n980av. They are matched on one cleaned form, letters and digits only, in uppercase. That fixed duplicates, and then caused a bug of its own: the cleaner stripped everything but uppercase letters and digits before uppercasing, so “n980av” became “980”.

Who wins

With several sources, the real question is precedence.

The user, then the provider, then research. An aircraft the user chose is never overwritten. Below that, a tail the airline publishes a day out is treated as a plan, not a fact, because aircraft get swapped, sometimes at the gate.

Research only fills gaps. When no provider knows an airframe, an LLM with web search looks it up, citing a source for each field. If a provider record turns up later, it wins, and research may only fill fields that are still empty. Before anything is written, a photo site has to confirm that the registration exists. That check is what stops a typo becoming a permanent airframe.

Provenance per field. Gate and terminal record who set them and when. TripIt may fill a gate only if it’s empty or if TripIt wrote it, and it may only undo a cancellation it made itself.

Plausible but wrong

Some data is well-formed and still impossible: arrival before departure, departure and arrival at the same airport, an implausible average speed, training and test flight numbers. One rule decides what the stats should ignore, so the filter and its inverse can’t disagree.

ADS-B flight paths get the same treatment: impossible jumps are dropped, and a path is drawn only with enough coverage.

In numbers

Community reference datasets 3
Import formats 8 apps + TripIt + email
IATA codes shared by more than one airline 79
Airport code aliases 4 pairs, both directions

Request
clearance