Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions chado/migrations/V1.3.3.010__add_environmental_fact_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Adds a new "nd_fact" table to store environmental data.
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,
timecapturedend 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.';
COMMENT ON COLUMN nd_fact.timecapturedend IS 'This optional value can be used to mark the end of the time that the catured fact data refers to, that is to provide a time span rather than a time point; can be null.';
20 changes: 20 additions & 0 deletions chado/modules/natural_diversity/natural_diversity.sql
Original file line number Diff line number Diff line change
Expand Up @@ -435,3 +435,23 @@ CREATE INDEX nd_experiment_analysis_idx2 ON nd_experiment_analysis (analysis_id)
CREATE INDEX nd_experiment_analysis_idx3 ON nd_experiment_analysis (type_id);

COMMENT ON TABLE nd_experiment_analysis IS 'An analysis that is used in an experiment';

-- ================================================
-- TABLE: nd_fact
-- ================================================

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,
timecapturedend 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.';
COMMENT ON COLUMN nd_fact.timecapturedend IS 'This optional value can be used to mark the end of the time that the catured fact data refers to, that is to provide a time span rather than a time point; can be null.';