Home / Blog / Tokaj is Hungarian. And Slovak.

August 11, 2026· Wine World Map

Tokaj is Hungarian. And Slovak.

The Tokaj appellation is famous for aszú, botrytis, and volcanic soils. It is also, geopolitically, in two countries. About 5,500 hectares are in northeastern Hungary. About 900 hectares are across the border in southeastern Slovakia, where the same soils and the same furmint grape produce wine sold as Tokajský/Tokajská. The two sides litigated the name for years. Both won. Both use it.

Our regions table was designed with a single country_id foreign key, because the overwhelming majority of wine regions sit neatly inside one country. Tokaj broke that assumption. So did Mosel. So did Collio-Brda. Here is what we did about it.

The naive schema

create table regions (
  id            uuid primary key,
  slug          text unique not null,
  name          text not null,
  country_id    uuid not null references countries(id),
  centroid      geography(point),
  boundary      geography(polygon),
  ...
);

That not null on country_id is doing real work. It powers the country pages, the flag emoji on region cards, the "wines from Slovakia" filter, and the URL structure /countries/hu/regions/tokaj. Making it nullable would have cascaded into a dozen UI branches.

The obvious alternative — a join table regions_countries with (region_id, country_id) — solves the modeling problem but adds a join to every query that renders a flag. And it still doesn't answer the question the UI actually asks: which country page does Tokaj live under?

What we did instead

We kept country_id as the primary country, added a nullable secondary_country_ids uuid[], and let the seed script decide which side wins.

alter table regions
  add column secondary_country_ids uuid[] not null default '{}';

create index regions_secondary_countries_gin
  on regions using gin (secondary_country_ids);

For Tokaj the primary is Hungary — the majority of the vineyard area, the older appellation, the one most readers mean when they say "Tokaji". Slovakia goes in the array. The country page for Slovakia queries both:

select * from regions
where country_id = $1
   or $1 = any(secondary_country_ids);

The array lives in secondary_country_ids rather than a join table for one reason: it never gets long. The maximum today is two. Mosel might eventually hit three (Germany, Luxembourg, France) if we decide the tiny Moselle AOC on the French bank deserves to be merged rather than kept as its own region. GIN over a short array is fine.

The cases that forced the column

| Region | Primary | Secondary | Notes | |---|---|---|---| | Tokaj | HU | SK | Same name, same soils, litigated | | Mosel | DE | LU | Luxembourg's Moselle is contiguous | | Collio / Brda | IT | SI | Same hills, two names, one wine style | | Jura | FR | — | Not the Slovenian one; different word | | Alsace | FR | — | Baden is across the Rhine but distinct AOC |

Collio and Goriška Brda are the interesting edge case. They are literally the same hillsides split by the 1947 border. We chose to model them as two regions because the appellation names, grape mixes, and producer cultures diverge enough that merging would mislead. But their polygons touch, and clicking either flies you into a view where you can see the other across the line. See the dedup post for the general logic about when to fold two things together.

What OSM does

OpenStreetMap sidesteps the problem by not modeling wine appellations as boundary objects at all in most of these cases. The Tokaj-Hegyalja boundary=protected_area relation exists on the Hungarian side; the Slovak side has nothing tagged as a wine region, only municipal boundaries. Our import falls back to landuse=vineyard hulls on the Slovak side, which — as covered in the hull post — gives us a serviceable polygon that traces where vines actually are. The resulting Tokaj outline is one Hungarian polygon and one Slovak polygon, unioned at render time, with a slug of tokaj and a flag showing HU.

The winery side

Wineries have a single country_id because a winery is a building and a building sits in exactly one country. Château Pajzos is in Hungary. Ostrožovič is in Slovakia. Both are linked to region:tokaj. The /regions/tokaj page lists them together, grouped by country, which is how tourists actually plan a Tokaj trip — you cross the border, taste on both sides, come home with bottles in two languages.

Lesson

The instinct when a foreign key breaks is to promote it to a join table. Usually the better move is to keep the primary relationship denormalized and add a short list for the exceptions. Borders on this planet are messy in a small, finite number of ways. Model the mess with the smallest structure that survives it, and let the URL structure — which is a product decision, not a data one — decide which country gets to say "our Tokaj."

#schema#appellations#borders