Chado icon indicating copy to clipboard operation
Chado copied to clipboard

Add a table to store environmental data

Open guignonv opened this issue 5 years ago • 5 comments

For people doing plant characterization or breeding, it may be useful to store environmental data (climatic data and other). Those data are related to a specific geo-location and are taken at a given time. Therefore I would tend to use the nd_geolcation table for geo-locations and add a nd_fact table:

CREATE TABLE nd_fact(
    nd_fact_id BIGSERIAL PRIMARY KEY NOT NULL,
    nd_geolocation_id BIGINT NOT NULL REFERENCES nd_geolocation (nd_geolocation_id) ON DELETE CASCADE INITIALLY DEFERRED,
    type_id BIGINT NOT NULL REFERENCES cvterm (cvterm_id) ON DELETE CASCADE INITIALLY DEFERRED,
    timecaptured TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    value TEXT NULL,
    CONSTRAINT nd_fact_c1 UNIQUE (nd_geolocation_id, type_id, timecaptured)
  );
CREATE INDEX nd_fact_idx1 ON nd_fact (nd_geolocation_id);
CREATE INDEX nd_fact_idx2 ON nd_fact (timecaptured);
COMMENT ON TABLE nd_fact IS 'The fact table contains facts (temparture, weather condition,...) at a given time for a given geolocation.';
COMMENT ON COLUMN nd_fact.value IS 'The value can be NULL if the type_id is self-explicit. For instance, if the type_id term is "sunny day", there is no need for a value.';

guignonv avatar May 10 '19 15:05 guignonv