critwire · Learn · Learn's data

Learn · Schemas: browser · lab · star

Schema: the browser's tables

The tables every browser lab and the playground run on. The page builds them in your browser from four published files, so every learner starts from the same rows, and a reload starts fresh.

Six tables describe the animals: taxa, species, countries, species_countries, sources and species_sources, read from /v1/species.parquet and /v1/countries.parquet. Two more hold the lab's sample of open GBIF records: datasets and occurrences, read from the lab data. A record is one observation of an animal at a place and time; the course counts records, and never presents them as where an animal lives.

The diagram

An entity–relationship diagram (ERD) draws each table as a box with its columns, and each foreign key as a line to the table it points at. PK marks the primary key, FK a foreign key, UK a unique key. The ends of a line say how many rows meet there: || exactly one, |o zero or one, o{ zero or more, |{ one or more. The end with the crow's foot is the table that holds the foreign key.

critwire Learn schema v2, the tables in the browser
Eight tables: taxa, species, countries, species_countries, sources and species_sources from schema v1, plus datasets and occurrences, the sample of GBIF records. Each line joins a foreign key to the table it points at. Open the diagram alone to zoom in.

The relationships, in words

A record's country is optional. country_code_gbif keeps GBIF's code as delivered, and country_code holds it only when it is a row of countries, so GBIF's ZZ (unknown) and XZ (high seas) never break the foreign key.

The view species_taxonomy

species_taxonomy (species_id, class, order_name, family, genus) gives each species its genus, family, order and class in one row, by walking taxa from the genus up through each parent_name. A view is a stored query, not a table: it holds no rows of its own, and reading it runs the query. That is why it isn't drawn.

The data dictionary

Every column: its type, its keys, what it means, and where its values come from.

taxa

ColumnTypeKeyMeaningSource
nameVARCHARPKAgalychnis, Phyllomedusidae, Anura, Amphibiacritwire /v1/species.parquet: taxonomy from Catalogue of Life, else critwire base
taxon_rankVARCHARclass, order, family or genuscritwire /v1/species.parquet: taxonomy from Catalogue of Life, else critwire base
parent_nameVARCHARFKthe taxon one rank up; NULL for a classcritwire /v1/species.parquet: taxonomy from Catalogue of Life, else critwire base

species

ColumnTypeKeyMeaningSource
idINTEGERPKcritwire's own id, never reusedcritwire /v1/species.parquet; each field's source is in species_sources
slugVARCHARUKred-eyed-tree-frogcritwire /v1/species.parquet; each field's source is in species_sources
scientific_nameVARCHARUKAgalychnis callidryascritwire /v1/species.parquet; each field's source is in species_sources
common_nameVARCHARRed-eyed Tree Frogcritwire /v1/species.parquet; each field's source is in species_sources
genusVARCHARFKa taxa row of rank genuscritwire /v1/species.parquet; each field's source is in species_sources
range_statusVARCHARok, no-open-records or identity-unsettledcritwire /v1/species.parquet; each field's source is in species_sources
photo_urlVARCHARNULL when there is no photocritwire /v1/species.parquet; each field's source is in species_sources
photo_creditVARCHARwho took the photocritwire /v1/species.parquet; each field's source is in species_sources
photo_licenseVARCHARCC BY-SA 4.0, CC BY 2.0, CC0, Public domaincritwire /v1/species.parquet; each field's source is in species_sources
photo_pageVARCHARthe photo's Wikimedia Commons pagecritwire /v1/species.parquet; each field's source is in species_sources
iucn_idINTEGERUKIUCN Red List taxon idcritwire /v1/species.parquet; each field's source is in species_sources
gbif_idBIGINTUKGBIF backbone taxon keycritwire /v1/species.parquet; each field's source is in species_sources
col_idVARCHARUKCatalogue of Life idcritwire /v1/species.parquet; each field's source is in species_sources
wikidata_idVARCHARUKWikidata itemcritwire /v1/species.parquet; each field's source is in species_sources
inaturalist_idINTEGERUKiNaturalist taxon idcritwire /v1/species.parquet; each field's source is in species_sources
ncbi_idINTEGERUKNCBI Taxonomy idcritwire /v1/species.parquet; each field's source is in species_sources

countries

ColumnTypeKeyMeaningSource
codeVARCHARPKISO 3166-1 alpha-2, plus XKcritwire /v1/countries.parquet
nameVARCHARUKBrazilcritwire /v1/countries.parquet
continentVARCHARSouth Americacritwire /v1/countries.parquet
regionVARCHARAmericascritwire /v1/countries.parquet
subregionVARCHARSouth Americacritwire /v1/countries.parquet

species_countries

ColumnTypeKeyMeaningSource
species_idINTEGERPK, FKthe animalcritwire /v1/species.parquet, range.countriesWithOpenRecords (GBIF, CC0 and CC BY records)
country_codeVARCHARPK, FKrecorded there in open recordscritwire /v1/species.parquet, range.countriesWithOpenRecords (GBIF, CC0 and CC BY records)

sources

ColumnTypeKeyMeaningSource
nameVARCHARPKWikidata, Catalogue of Life, critwire basecritwire /v1/species.parquet, sources[]
licenseVARCHARthe license of what critwire tookcritwire /v1/species.parquet, sources[]
retrievedDATEwhen critwire took it; NULL for critwire basecritwire /v1/species.parquet, sources[]

species_sources

ColumnTypeKeyMeaningSource
species_idINTEGERPK, FKthe animalcritwire /v1/species.parquet, sources[]
fieldVARCHARPKa path in the record, such as ids.colcritwire /v1/species.parquet, sources[]
source_nameVARCHARFKwho supplied that fieldcritwire /v1/species.parquet, sources[]

datasets

ColumnTypeKeyMeaningSource
dataset_keyVARCHARPKGBIF's dataset idGBIF registry: the download's datasets (datasets.csv)
titleVARCHARthe dataset's own titleGBIF registry: the download's datasets (datasets.csv)
publisherVARCHARthe organization that published itGBIF registry: the download's datasets (datasets.csv)
doiVARCHARthe dataset's DOI; NULL when it has noneGBIF registry: the download's datasets (datasets.csv)
licenseVARCHARthe license the dataset declaresGBIF registry: the download's datasets (datasets.csv)

occurrences

ColumnTypeKeyMeaningSource
idBIGINTPKGBIF's record idGBIF occurrence download, sampled (cited in the credits)
species_idINTEGERFKthe animal recordedGBIF occurrence download, sampled (cited in the credits)
dataset_keyVARCHARFKthe dataset to creditGBIF occurrence download, sampled (cited in the credits)
licenseVARCHARCC0 1.0 or CC BY 4.0, the stricter of record and datasetGBIF record and dataset licenses
basis_of_recordVARCHARHUMAN_OBSERVATION, PRESERVED_SPECIMEN, ...GBIF occurrence download, sampled (cited in the credits)
longitudeDOUBLEdegrees east, WGS 84GBIF occurrence download, sampled (cited in the credits)
latitudeDOUBLEdegrees north, WGS 84GBIF occurrence download, sampled (cited in the credits)
coordinate_uncertainty_mDOUBLEmetres; NULL when not givenGBIF occurrence download, sampled (cited in the credits)
country_code_gbifVARCHARGBIF's code as delivered; ZZ unknown, XZ high seasGBIF occurrence download, sampled (cited in the credits)
country_codeVARCHARFKthat code when it is a countries row, else NULLcountry_code_gbif, when a countries row
yearINTEGERNULL when the record has noneGBIF occurrence download, sampled (cited in the credits)
monthINTEGER1 to 12; NULL when the record has noneGBIF occurrence download, sampled (cited in the credits)