Importing base schema

This commit is contained in:
Matthew Dillon 2014-10-16 09:41:01 -08:00
parent 7e74d672ba
commit b045ded9cd
16 changed files with 170 additions and 0 deletions

View file

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

View file

@ -0,0 +1,20 @@
-- bactdb
-- Matthew R Dillon
CREATE TABLE strains (
id BIGSERIAL NOT NULL,
species_id BIGINT,
strain_name CHARACTER VARYING(100),
strain_type CHARACTER VARYING(100),
etymology CHARACTER VARYING(500),
accession_banks CHARACTER VARYING(100),
genbank_embl_ddb CHARACTER VARYING(100),
created_at TIMESTAMP WITH TIME ZONE,
updated_at TIMESTAMP WITH TIME ZONE,
deleted_at TIMESTAMP WITH TIME ZONE,
CONSTRAINT strain_pkey PRIMARY KEY (id),
FOREIGN KEY (species_id) REFERENCES species(id)
);

View file

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

View file

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

View file

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

View file

@ -0,0 +1,16 @@
-- bactdb
-- Matthew R Dillon
CREATE TABLE observations (
id BIGSERIAL NOT NULL,
observation_name CHARACTER VARYING(100),
observation_type_id BIGINT,
created_at TIMESTAMP WITH TIME ZONE,
updated_at TIMESTAMP WITH TIME ZONE,
deleted_at TIMESTAMP WITH TIME ZONE,
CONSTRAINT observations_pkey PRIMARY KEY (id),
FOREIGN KEY (observation_type_id) REFERENCES observation_types(id)
);

View file

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

View file

@ -0,0 +1,17 @@
-- 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

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

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,17 @@
-- bactdb
-- Matthew R Dillon
CREATE TABLE numerical_measurements (
id BIGSERIAL NOT NULL,
measurement_value NUMERIC(6, 4) NOT NULL,
confidence_interval NUMERIC(6,4) NULL,
unit_type_id BIGINT,
created_at TIMESTAMP WITH TIME ZONE,
updated_at TIMESTAMP WITH TIME ZONE,
deleted_at TIMESTAMP WITH TIME ZONE,
CONSTRAINT numerical_measurements_pkey PRIMARY KEY (id),
FOREIGN KEY (unit_type_id) REFERENCES unit_types(id)
);

View file

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

View file

@ -0,0 +1,17 @@
-- bactdb
-- Matthew R Dillon
CREATE TABLE strainsobsmeasurements (
id BIGSERIAL NOT NULL,
strainsobservations_id BIGINT,
measurement_table CHARACTER VARYING(15),
measurement_id BIGINT,
created_at TIMESTAMP WITH TIME ZONE,
updated_at TIMESTAMP WITH TIME ZONE,
deleted_at TIMESTAMP WITH TIME ZONE,
CONSTRAINT strainsobsmeasurements_pkey PRIMARY KEY (id),
FOREIGN KEY (strainsobservations_id) REFERENCES strainsobservations(id)
);