Gapminder Concepts And Entities
Concept dictionary and entity (geo) reference tables for joining with per-indicator datasets
@gapminder.metadata
Concept dictionary and entity (geo) reference tables for joining with per-indicator datasets
@gapminder.metadata
Gapminder data is split into two kinds of datasets you combine via simple joins:
@gapminder.metadata ← (this dataset)
@gapminder.metadata.concepts): one row per indicator, identified by a concept id.@gapminder.metadata.entities_*): reference tables for codes like geo (countries/areas)entities_geo_country (key: geo) — country/area names and attributes. Often includes columns likeworld_4region, world_6region, income_groups, which point to group tables below.entities_geo_world_4region, entities_geo_world_6region, entities_geo_income_groups,entities_geo_income_3groups, entities_geo_unicef_region, entities_geo_unhcr_region,entities_geo_g77_and_oecd_countries, entities_geo_landlocked, entities_geo_global, etc.entities_gender, and topical vocabularies like entities_tag.Per-indicator datasets (one per concept in @gapminder.metadata.concepts)
@gapminder.age_at_1st_marriage_women,@gapminder.adults_with_hiv_percent_age_15_49.<concept_id>_by_<dimensions> (most often <concept_id>_by_geo_time)─────────────────────────────────────────────────────────────────────────────
Pick an indicator
concept id.name, description (and unit/format if present) to confirm it matches your intent.Retrieve the datapoints
<concept_id>_by_geo_time) to get values by geo and time.Add readable labels and groupings
geo → @gapminder.metadata.entities_geo_country.geoname, name_short, name_long, and attributes like world_4region, income_groups, etc.world_4region), then join to the matching region tableworld_4region) to get region names/colors/shapes.─────────────────────────────────────────────────────────────────────────────
-- Concept metadata (labels/units)
SELECT name, description
FROM @gapminder.metadata.concepts
WHERE concept = '<concept_id>';
-- Country names and region membership
SELECT d.time,
c.name AS country,
c.world_4region AS region_code,
r.name AS region_name,
d.<concept_id> AS value
FROM @gapminder.<concept_id>.<concept_id>_by_geo_time d
JOIN @gapminder.metadata.entities_geo_country c ON d.geo = c.country
LEFT JOIN @gapminder.metadata.entities_geo_world_4region r ON c.world_4region = r.world_4region;
-- Income groups example
SELECT d.time, c.name AS country, ig.name AS income_group, d.<concept_id> AS value
FROM @gapminder.<concept_id>.<concept_id>_by_geo_time d
JOIN @gapminder.metadata.entities_geo_country c ON d.geo = c.country
LEFT JOIN @gapminder.metadata.entities_geo_income_groups ig ON c.income_groups = ig.income_groups;
─────────────────────────────────────────────────────────────────────────────
geo codes may include aggregates (regions/world); treat aggregates differently from countries.time (year). Some concepts may use other time forms—check the table schema.TL;DR: Use @gapminder.metadata.concepts to interpret indicators and @gapminder.metadata.entities_*
to label countries and groupings; then query the per-concept datasets (e.g., @gapminder.age_at_1st_marriage_women) for the actual values and join on geo (and group keys) as shown above.
CREATE TABLE entities_geo_world_4region (
"world_4region" VARCHAR,
"color" VARCHAR,
"description" VARCHAR,
"is_world_4region" VARCHAR -- Is--world 4region,
"latitude" DOUBLE,
"longitude" DOUBLE,
"name" VARCHAR,
"name_long" VARCHAR,
"name_short" VARCHAR,
"rank" BIGINT,
"shape_lores_svg" VARCHAR
);Anyone who has the link will be able to view this.