Data Model

The data model of fishdata is designed to minimise duplication of data and split out disparate components. For this reason, almost any analysis while require joining across multiple tables, and therefore an understanding of the data model is needed.

There are two classes of data in fishdata: ‘Adult’ and ‘Juvenile’, referring to the respective age classes of Galaxis maculatus. These age classes have corresponding tables; adults, and juveniles. These two tables have one row per fish, and contain information about the catch date and location.

%0 adults adults fish_code site day catch_date juveniles juveniles fish_code fish otolith_code site day month catch_date

From these tables, you can then link to the corresponding metrics tables (adult_metrics and juvenile_metrics). These tables add information around age, birthdate, and growth rates.

This is a 1:1 relation, and is executed by joining on the fish_code column in both tables.

fish_dm <- dm(adult_metrics,
              adults,
              juvenile_metrics,
              juveniles)

fish_dm_pk <-
  fish_dm %>%
  dm_add_pk(table = adults, columns = fish_code) %>%
  dm_add_pk(juveniles, fish_code)

fish_dm_all_keys <-
  fish_dm_pk %>%
  dm_add_fk(adult_metrics, fish_code, adults) %>%
  dm_add_fk(juvenile_metrics, fish_code, juveniles)

dm_draw(fish_dm_all_keys, view_type = "all")
%0 adult_metrics adult_metrics fish_code standard_length body_depth age birthdate growth_rate adults adults fish_code site day catch_date adult_metrics:fish_code->adults:fish_code juvenile_metrics juvenile_metrics fish_code standard_length body_depth age birthdate growth_rate early_growth late_growth juveniles juveniles fish_code fish otolith_code site day month catch_date juvenile_metrics:fish_code->juveniles:fish_code

Finally, there are also corresponding growth tables (adult_growth and juvenile_growth). These contain daily measurements of otolith growth for each fish. This otolith growth can be subsequently used to estimate somatic growth.

As a single fish will have many days of growth, this is a 1:many relation, and is executed by joining on the fish_code column in both tables.

%0 adult_growth adult_growth fish_code period position distance adults adults fish_code site day catch_date adult_growth:fish_code->adults:fish_code adult_metrics adult_metrics fish_code standard_length body_depth age birthdate growth_rate adult_metrics:fish_code->adults:fish_code juvenile_growth juvenile_growth fish_code otolith_code period position distance juveniles juveniles fish_code fish otolith_code site day month catch_date juvenile_growth:fish_code->juveniles:fish_code juvenile_metrics juvenile_metrics fish_code standard_length body_depth age birthdate growth_rate early_growth late_growth juvenile_metrics:fish_code->juveniles:fish_code

For some examples of how to use this data in practise, check out the ‘Examples’ vignette.