From 0d6985a3ab82c80075cab39b6aecf772797b2f3e Mon Sep 17 00:00:00 2001 From: Dmitry Ilyn Date: Wed, 17 Oct 2018 15:18:30 +0300 Subject: [PATCH] PostgreSQL fixes --- .../OMOP CDM postgresql constraints.txt | 19 +++---------------- PostgreSQL/OMOP CDM postgresql ddl.txt | 6 +++--- PostgreSQL/OMOP CDM postgresql pk indexes.txt | 5 ----- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/PostgreSQL/OMOP CDM postgresql constraints.txt b/PostgreSQL/OMOP CDM postgresql constraints.txt index 0f41d65..4dd54a0 100644 --- a/PostgreSQL/OMOP CDM postgresql constraints.txt +++ b/PostgreSQL/OMOP CDM postgresql constraints.txt @@ -86,7 +86,7 @@ ALTER TABLE relationship ADD CONSTRAINT fpk_relationship_reverse FOREIGN KEY (re ALTER TABLE concept_synonym ADD CONSTRAINT fpk_concept_synonym_concept FOREIGN KEY (concept_id) REFERENCES concept (concept_id); -ALTER TABLE concept_synonym ADD CONSTRAINT fpk_concept_synonym_concept FOREIGN KEY (language_concept_id) REFERENCES concept (concept_id); +ALTER TABLE concept_synonym ADD CONSTRAINT fpk_concept_synonym_language_concept FOREIGN KEY (language_concept_id) REFERENCES concept (concept_id); ALTER TABLE concept_ancestor ADD CONSTRAINT fpk_concept_ancestor_concept_1 FOREIGN KEY (ancestor_concept_id) REFERENCES concept (concept_id); @@ -167,15 +167,6 @@ ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_site_concept FOREIGN KEY (anato ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_status_concept FOREIGN KEY (disease_status_concept_id) REFERENCES concept (concept_id); -ALTER TABLE death ADD CONSTRAINT fpk_death_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE death ADD CONSTRAINT fpk_death_type_concept FOREIGN KEY (death_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE death ADD CONSTRAINT fpk_death_cause_concept FOREIGN KEY (cause_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE death ADD CONSTRAINT fpk_death_cause_concept_s FOREIGN KEY (cause_source_concept_id) REFERENCES concept (concept_id); - - ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_person FOREIGN KEY (person_id) REFERENCES person (person_id); ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_concept FOREIGN KEY (visit_concept_id) REFERENCES concept (concept_id); @@ -188,8 +179,6 @@ ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_care_site FOREIGN KEY (car ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_concept_s FOREIGN KEY (visit_source_concept_id) REFERENCES concept (concept_id); -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_admitting_s FOREIGN KEY (admitting_source_concept_id) REFERENCES concept (concept_id); - ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_discharge FOREIGN KEY (discharge_to_concept_id) REFERENCES concept (concept_id); ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_preceding FOREIGN KEY (preceding_visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); @@ -207,8 +196,6 @@ ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_care_site FOREIGN KEY (care ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_discharge FOREIGN KEY (discharge_to_concept_id) REFERENCES concept (concept_id); -ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_admitting_s FOREIGN KEY (admitting_source_concept_id) REFERENCES concept (concept_id); - ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_concept_s FOREIGN KEY (visit_detail_source_concept_id) REFERENCES concept (concept_id); ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_preceding FOREIGN KEY (preceding_visit_detail_id) REFERENCES visit_detail (visit_detail_id); @@ -370,11 +357,11 @@ ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_source FOREIGN KEY (survey_ ALTER TABLE survey_conduct ADD CONSTRAINT fpk_validation FOREIGN KEY (validated_survey_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit (visit_occurrence_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_v_detail FOREIGN KEY (visit_detail_id) REFERENCES visit_detail (visit_detail_id); -ALTER TABLE survey_conduct ADD CONSTRAINT fpk_response_visit FOREIGN KEY (response_visit_occurrence_id) REFERENCES visit (visit_occurrence_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_response_visit FOREIGN KEY (response_visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_domain_1 FOREIGN KEY (domain_concept_id_1) REFERENCES concept (concept_id); diff --git a/PostgreSQL/OMOP CDM postgresql ddl.txt b/PostgreSQL/OMOP CDM postgresql ddl.txt index e2556e7..54f984a 100644 --- a/PostgreSQL/OMOP CDM postgresql ddl.txt +++ b/PostgreSQL/OMOP CDM postgresql ddl.txt @@ -211,9 +211,9 @@ CREATE TABLE metadata ) ; -INSERT INTO metadata (metadata_concept_id, metadata_type_concept_id, name, value_as_string, value_as_concept_id, metadata_date, metadata_datetime) -VALUES (0, 0, 'CDM Version', '6.0', 0, NULL, NULL) -; +--INSERT INTO metadata (metadata_concept_id, metadata_type_concept_id, name, value_as_string, value_as_concept_id, metadata_date, metadata_datetime) +--VALUES (0, 0, 'CDM Version', '6.0', 0, NULL, NULL) +--; /************************ diff --git a/PostgreSQL/OMOP CDM postgresql pk indexes.txt b/PostgreSQL/OMOP CDM postgresql pk indexes.txt index 7776979..4d6590d 100644 --- a/PostgreSQL/OMOP CDM postgresql pk indexes.txt +++ b/PostgreSQL/OMOP CDM postgresql pk indexes.txt @@ -101,8 +101,6 @@ ALTER TABLE observation_period ADD CONSTRAINT xpk_observation_period PRIMARY KEY ALTER TABLE specimen ADD CONSTRAINT xpk_specimen PRIMARY KEY ( specimen_id ) ; -ALTER TABLE death ADD CONSTRAINT xpk_death PRIMARY KEY ( person_id ) ; - ALTER TABLE visit_occurrence ADD CONSTRAINT xpk_visit_occurrence PRIMARY KEY ( visit_occurrence_id ) ; ALTER TABLE visit_detail ADD CONSTRAINT xpk_visit_detail PRIMARY KEY ( visit_detail_id ) ; @@ -253,9 +251,6 @@ CREATE INDEX idx_specimen_person_id ON specimen (person_id ASC); CLUSTER specimen USING idx_specimen_person_id ; CREATE INDEX idx_specimen_concept_id ON specimen (specimen_concept_id ASC); -CREATE INDEX idx_death_person_id ON death (person_id ASC); -CLUSTER death USING idx_death_person_id ; - CREATE INDEX idx_visit_person_id ON visit_occurrence (person_id ASC); CLUSTER visit_occurrence USING idx_visit_person_id ; CREATE INDEX idx_visit_concept_id ON visit_occurrence (visit_concept_id ASC);