afsc-gap-products / gap_products

This repository supports code used to create tables in the GAP_PRODUCTS Oracle schema. These tables include the master production tables, tables shared with AKFIN, and tables publicly shared on FOSS.
https://afsc-gap-products.github.io/gap_products/
Creative Commons Zero v1.0 Universal
6 stars 6 forks source link

Add Year column to "AKFIN_SPECIMEN" #46

Closed Lee-Cronin-Fine-NOAA closed 2 months ago

Lee-Cronin-Fine-NOAA commented 4 months ago

Issue

I was pulling the length-weight data for my assessment from the "AKFIN_SPECIMEN" table and noticed there is no column that indicates the year in which the data was collected. This information would be valuable to have since it would allow assessment authors to see if there has been a change in the length-weight relationship over years. I was wondering if it would be possible to add this column to the "AKFIN_SPECIMEN" table?

zoyafuso-NOAA commented 3 months ago

Hi Lee,

I agree this information is important. To reduce redundancies, only the key bits of info for a table are included (to the extent possible) and the idea is to join other akfin_* tables to get axillary information (like year, vessel, region, lat/lon, etc.). For example, the YEAR column can be extracted from akfin_cruise (with key field cruisejoin) and it can then be joined with the akfin_specimen table via the hauljoin key. Try out this example below and you can add further WHERE clauses after the two JOIN lines

select * from gap_products.akfin_specimen 
join (select hauljoin, cruisejoin from gap_products.akfin_haul) using (HAULJOIN)
join (select cruisejoin, year from gap_products.akfin_cruise) using (CRUISEJOIN)
zoyafuso-NOAA commented 3 months ago

Hey @Lee-Cronin-Fine-NOAA ,

Just checking in on this issue. Did you find this code helpful or is there something I can clarify further?

Thanks, Zack

Lee-Cronin-Fine-NOAA commented 2 months ago

Hey Zack,

The code you gave me worked.

Thanks for the help and checking in.

Sorry for the late reply.

Lee