Conventions
Names
Datasets are named for their data domain and the analysis that produced them, never for a client. Several clients query the same national tables.
<domain>_<analysis>_<content>_<grain> e.g. workforce_01_tightness_msa_year
The domain is also the database schema, so that table is
workforce.workforce_01_tightness_msa_year. The last part of the name is
the grain.
Grain
Every dataset declares a grain: what one row represents. msa-year means
one row per metro area per year. msa means one row per metro area.
Parts are joined with hyphens, largest unit first, time last. Common grains
are msa, msa-year, state-year, county-year, msa-naics2-year,
soc-msa, and soc-msa-year.
Never join two tables of different grain without aggregating first.
Joining an msa-year table to an msa table without collapsing years
repeats each metro once per year and inflates every sum.
Wrong:
SELECT a.cbsa, SUM(a.openings), SUM(b.population)
FROM workforce.some_msa_year_table a
JOIN workforce.some_msa_table b USING (cbsa)
GROUP BY a.cbsa; -- population is counted once per year
Right: bring both tables to the same grain, say so, then join.
WITH yearly AS ( -- collapse msa-year to msa
SELECT cbsa, SUM(openings) AS openings
FROM workforce.some_msa_year_table
GROUP BY cbsa
)
SELECT y.cbsa, y.openings, b.population
FROM yearly y
JOIN workforce.some_msa_table b USING (cbsa);
Codes are strings
CBSA, FIPS, NAICS, and SOC codes are stored as text. Leading zeros matter.
Compare them as strings: WHERE cbsa = '01234', not WHERE cbsa = 1234.
Vintage
A vintage is a string like 2026-09. It names one data pull.
- Each dataset has its own vintage, set by when its sources were last
pulled. One at
2026-03and another at2026-09is normal. - Two datasets built from the same pull share a vintage, even when they sit in different domains.
- A published vintage is never edited. If a processing fix changes the
numbers without a new pull, the dataset gets a revision:
2026-09.r2. - A wording fix (a new caveat, a clearer definition) changes the documentation only. The vintage stays the same.
Every table has two extra columns: _vintage and _dataset_id. Do not add
or average across datasets unless their _vintage values come from the
same pull. 2026-09 and 2026-09.r2 do; 2026-03 and 2026-09 do not.
Citation
Each dataset has a citation field. Use it verbatim. Do not paraphrase it
and do not drop the vintage. The format is:
Moonlight Analytics (<year>). <title>, vintage <vintage>.
Derived from <sources>.
Example datasets
A dataset whose title starts with EXAMPLE: is synthetic. It is not in the
database. Do not cite it, analyze it, or report its numbers as findings.