Difference between revisions of "CIMMYT Wheat Breeding Database"
(Created page with "The CIMMYT wheat breading database contains phenotypic field data that was collected for CIMMYT experiments collected at multiple locations. The CIMMYT wheat breeding databa...")
Revision as of 20:19, 12 June 2017
The CIMMYT wheat breading database contains phenotypic field data that was collected for CIMMYT experiments collected at multiple locations.
The CIMMYT wheat breeding database schema is shown in the figure below:
FOR QUERY OF REPEATED MEASUREMENTS: This query can be used to extract a column format of a repeat measurements (over dates) for multiple traits.
The query below is an example of how to generate a report of the G-NDVI and R-NDVI traits from the 16OBR plots with B2I conditions, (bed planting and two irrigations) for the Elite Yield Trial (EYT).
SET SESSION group_concat_max_len = 10000; USE CIMMYT; SET @SQL = NULL; CREATE TEMPORARY TABLE IF NOT EXISTS p AS (SELECT * FROM phenotypes WHERE (YEAR(phenotype_date) = 2016 AND phenotype_value IS NOT NULL AND plot_id LIKE '16-OBR-B2I-EYT%' AND trait_id LIKE '%NDVI%')); SELECT GROUP_CONCAT(DISTINCT CONCAT('MAX(IF(p.phenotype_date = ''', `phenotype_date`, ''',p.phenotype_value,NULL)) AS ''', `phenotype_date`,'''') ORDER BY `phenotype_date` ASC ) INTO @SQL FROM p; SET @SQL = CONCAT('SELECT p.plot_id,p.trait_id, ', @SQL, ' FROM p GROUP BY p.plot_id,p.trait_id ORDER BY p.plot_id'); PREPARE stmt FROM @SQL; EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TEMPORARY TABLE p;