critwire · Learn · Learn's data

Learn · Schemas: browser · lab · star

Star schema: what Power BI reads

A star schema built from the lab data for reporting: CSV files under /learn/data/star/, which Power BI Desktop loads by URL. The database architecture track builds the same star in SQL.

A star puts the numbers to add up in fact tables, one row per event at a fixed grain, and the words to filter and group by in dimension tables around them. fact_records has one row per sample record. fact_species_country has no measure at all: a row says that a species has open records in a country, and counting rows is the analysis (a factless fact).

Both share dim_species and dim_country. A dimension two facts share is conformed: one slicer on species or country filters both. The habitat fact, fact_country_habitat, shares only dim_country; it has no species, and its areas are estimates from a habitat map, not measurements.

Every foreign key in a fact is filled. A record with no year points at dim_year's -1 row, and one in no country at dim_country's ZZ row: an unknown member. So every line is "exactly one" on the dimension's side, and no record falls out of a report because a key was empty.

The diagram

PK primary key, FK foreign key; || exactly one, o{ zero or more, with the crow's foot on the fact that holds the foreign key.

critwire Learn Power BI star
Two facts, fact_records (one row per sample record) and fact_species_country (no measure), share the dimensions dim_species and dim_country; fact_records also points at dim_dataset and dim_year. A third fact, fact_country_habitat (estimated area per country and habitat class), shares dim_country and points at dim_habitat_class. Open the diagram alone to zoom in.

The relationships, in words

The data dictionary

Every column, with a link to each published file.

dim_species dim_species.csv

ColumnTypeKeyMeaningSource
species_idINTEGERPKcritwire's species idspecies and species_taxonomy
scientific_nameVARCHARSarcophilus harrisiispecies and species_taxonomy
common_nameVARCHARTasmanian Devilspecies and species_taxonomy
classVARCHARMammaliaspecies and species_taxonomy
order_nameVARCHARDasyuromorphiaspecies and species_taxonomy
familyVARCHARDasyuridaespecies and species_taxonomy
genusVARCHARSarcophilusspecies and species_taxonomy

dim_country dim_country.csv

ColumnTypeKeyMeaningSource
country_codeVARCHARPKISO alpha-2; ZZ the unknown membercountries, plus the ZZ member
nameVARCHARAustralia; Unknown or outside any country for ZZcountries, plus the ZZ member
continentVARCHAROceaniacountries, plus the ZZ member
regionVARCHAROceaniacountries, plus the ZZ member
subregionVARCHARAustralia and New Zealandcountries, plus the ZZ member

dim_dataset dim_dataset.csv

ColumnTypeKeyMeaningSource
dataset_keyVARCHARPKGBIF's dataset iddatasets
titleVARCHARthe dataset's title, to creditdatasets
publisherVARCHARwho published itdatasets
doiVARCHARits DOI; empty when it has nonedatasets
licenseVARCHARthe license the dataset declaresdatasets

dim_year dim_year.csv

ColumnTypeKeyMeaningSource
yearINTEGERPKa year with records; -1 the unknown memberoccurrences.year, plus the -1 member
decadeINTEGER2010; empty for -1computed from year
labelVARCHAR2016; Unknown for -1computed from year

fact_records fact_records.csv

ColumnTypeKeyMeaningSource
record_idBIGINTPKGBIF's record id; grain: one recordoccurrences
species_idINTEGERFKthe animaloccurrences
country_codeVARCHARFKwhere; ZZ when unknownoccurrences
dataset_keyVARCHARFKwhose recordoccurrences
yearINTEGERFKwhen; -1 when unknownoccurrences
monthINTEGER1 to 12, or emptyoccurrences
basis_of_recordVARCHARdegenerate dimensionoccurrences
licenseVARCHARdegenerate dimension: CC0 1.0 or CC BY 4.0occurrences
longitudeDOUBLEfor map visualsoccurrences
latitudeDOUBLEfor map visualsoccurrences
coordinate_uncertainty_mDOUBLEmetres, or emptyoccurrences

fact_species_country fact_species_country.csv

ColumnTypeKeyMeaningSource
species_idINTEGERPK, FKthe animalspecies_countries
country_codeVARCHARPK, FKa country with open records of itspecies_countries

dim_habitat_class dim_habitat_class.csv

ColumnTypeKeyMeaningSource
habitat_codeINTEGERPKJung v004 classhabitat_classes
nameVARCHARthe classhabitat_classes
level1_codeINTEGERits level-1 class; a level-1 class is its ownhabitat_classes
level1_nameVARCHARthe level-1 class's namehabitat_classes, its level-1 row

fact_country_habitat fact_country_habitat.csv

ColumnTypeKeyMeaningSource
country_codeVARCHARPK, FKthe countrycountry_habitats
habitat_codeINTEGERPK, FKthe habitat classcountry_habitats
est_area_km2DECIMALestimated area, km2country_habitats