Adding table ‘test_methods’

This commit is contained in:
Matthew Dillon 2014-12-03 15:25:59 -09:00
parent b15eb217ef
commit 3d2dd015a2
4 changed files with 23 additions and 0 deletions

View file

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

View file

@ -0,0 +1,14 @@
-- bactdb
-- Matthew R Dillon
CREATE TABLE test_methods (
id BIGSERIAL NOT NULL,
name CHARACTER VARYING(100) NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
deleted_at TIMESTAMP WITH TIME ZONE NULL,
CONSTRAINT test_methods_pkey PRIMARY KEY (id)
);

View file

@ -11,6 +11,7 @@ CREATE TABLE measurements (
confidence_interval NUMERIC(8, 3) NULL,
unit_type_id BIGINT NULL,
notes CHARACTER VARYING(255) NULL,
test_method_id BIGINT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
@ -20,6 +21,7 @@ CREATE TABLE measurements (
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),
FOREIGN KEY (test_method_id) REFERENCES test_methods(id),
CONSTRAINT exclusive_data_type CHECK (
(text_measurement_type_id IS NOT NULL
AND txt_value IS NULL
@ -46,3 +48,5 @@ CREATE INDEX text_measurement_type_id_idx ON measurements (text_measurement_type
CREATE INDEX unit_type_id_idx ON measurements (unit_type_id);
CREATE INDEX test_method_id_idx ON measurements (test_method_id);