Consolidating strainsobservations & measurements.

This commit is contained in:
Matthew Dillon 2014-11-26 16:47:57 -09:00
parent 5bee929694
commit aadb24bf33
8 changed files with 4 additions and 24 deletions

View file

@ -1,5 +0,0 @@
-- bactdb
-- Matthew R Dillon
DROP TABLE strainsobservations;

View file

@ -1,17 +0,0 @@
-- bactdb
-- Matthew R Dillon
CREATE TABLE strainsobservations (
id BIGSERIAL NOT NULL,
strain_id BIGINT NOT NULL,
observations_id BIGINT NOT NULL,
created_at TIMESTAMP WITH TIME ZONE,
updated_at TIMESTAMP WITH TIME ZONE,
deleted_at TIMESTAMP WITH TIME ZONE,
CONSTRAINT strainsobservations_pkey PRIMARY KEY (id),
FOREIGN KEY (strain_id) REFERENCES strains(id),
FOREIGN KEY (observations_id) REFERENCES observations(id)
);

View file

@ -3,7 +3,8 @@
CREATE TABLE measurements (
id BIGSERIAL NOT NULL,
strainsobservations_id BIGINT,
strain_id BIGINT,
observation_id BIGINT,
text_measurement_type_id BIGINT NULL,
measurement_value NUMERIC(6, 4) NULL,
confidence_interval NUMERIC(6, 4) NULL,
@ -14,7 +15,8 @@ CREATE TABLE measurements (
deleted_at TIMESTAMP WITH TIME ZONE,
CONSTRAINT strainsobsmeasurements_pkey PRIMARY KEY (id),
FOREIGN KEY (strainsobservations_id) REFERENCES strainsobservations(id),
FOREIGN KEY (strain_id) REFERENCES strains(id),
FOREIGN KEY (observation_id) REFERENCES observations(id),
FOREIGN KEY (text_measurement_type_id) REFERENCES text_measurement_types(id),
FOREIGN KEY (unit_type_id) REFERENCES unit_types(id),
CONSTRAINT exclusive_data_type CHECK (