Menu

The same shipping event, twice, in two languages: a dedup rule we measured and did not ship
📰

The same shipping event, twice, in two languages: a dedup rule we measured and did not ship

DEV Community: database·24hTrack·2 days ago
#GBrTFsew
#devtodatabase#devto#dev#event#carrier
Reading 0:00
15s threshold

If you store carrier scan events, you will eventually meet a timeline where every row appears twice: once in English, once in another script, with the identical timestamp. Some postal operators publish each event in more than one language, and if you persist what the carrier published, you persist both.

The obvious fix is a dedup rule. This is the story of why we measured one, found it destroys real data, and shipped nothing.

Why the naive key is wrong in both directions

Most event tables end up keyed on something like:

UNIQUE KEY uk_event ( tracking_number , event_date , description )

Enter fullscreen mode

Exit fullscreen mode

That key is wrong twice over.

It under-dedups. Two rows for one event differ in description (different language), so both survive. The customer counts rows and concludes the parcel went through sorting twice as often as it did.

And it over-dedups the moment you "fix" it.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.