Updated netezza with distribution

This commit is contained in:
Blacketer 2017-12-01 13:37:53 -05:00
parent 227ecc531a
commit 461a85fb6d
2 changed files with 193 additions and 0 deletions

View File

@ -243,6 +243,7 @@ CREATE TABLE person
ethnicity_source_value VARCHAR(50) NULL,
ethnicity_source_concept_id INTEGER NULL
)
DISTRIBUTE ON (person_id)
;
@ -255,6 +256,7 @@ CREATE TABLE observation_period
observation_period_end_date DATE NOT NULL ,
period_type_concept_id INTEGER NOT NULL
)
DISTRIBUTE ON (person_id)
;
@ -277,6 +279,7 @@ CREATE TABLE specimen
anatomic_site_source_value VARCHAR(50) NULL ,
disease_status_source_value VARCHAR(50) NULL
)
DISTRIBUTE ON (person_id)
;
@ -291,6 +294,7 @@ CREATE TABLE death
cause_source_value VARCHAR(50) NULL,
cause_source_concept_id INTEGER NULL
)
DISTRIBUTE ON (person_id)
;
@ -315,6 +319,7 @@ CREATE TABLE visit_occurrence
discharge_to_source_value VARCHAR(50) NULL ,
preceding_visit_occurrence_id INTEGER NULL
)
DISTRIBUTE ON (person_id)
;
@ -341,6 +346,7 @@ CREATE TABLE visit_detail
visit_detail_parent_id INTEGER NULL ,
visit_occurrence_id INTEGER NOT NULL
)
DISTRIBUTE ON (person_id)
;
@ -362,6 +368,7 @@ CREATE TABLE procedure_occurrence
procedure_source_concept_id INTEGER NULL ,
modifier_source_value VARCHAR(50) NULL
)
DISTRIBUTE ON (person_id)
;
@ -392,6 +399,7 @@ CREATE TABLE drug_exposure
route_source_value VARCHAR(50) NULL ,
dose_unit_source_value VARCHAR(50) NULL
)
DISTRIBUTE ON (person_id)
;
@ -414,6 +422,7 @@ CREATE TABLE device_exposure
device_source_value VARCHAR(100) NULL ,
device_source_concept_id INTEGER NULL
)
DISTRIBUTE ON (person_id)
;
@ -437,6 +446,7 @@ CREATE TABLE condition_occurrence
condition_status_source_value VARCHAR(50) NULL ,
condition_status_concept_id INTEGER NULL
)
DISTRIBUTE ON (person_id)
;
@ -464,6 +474,7 @@ CREATE TABLE measurement
unit_source_value VARCHAR(50) NULL ,
value_source_value VARCHAR(50) NULL
)
DISTRIBUTE ON (person_id)
;
@ -485,6 +496,7 @@ CREATE TABLE note
visit_detail_id INTEGER NULL ,
note_source_value VARCHAR(50) NULL
)
DISTRIBUTE ON (person_id)
;
@ -531,6 +543,7 @@ CREATE TABLE observation
unit_source_value VARCHAR(50) NULL ,
qualifier_source_value VARCHAR(50) NULL
)
DISTRIBUTE ON (person_id)
;
@ -626,6 +639,7 @@ CREATE TABLE payer_plan_period
stop_reason_source_value INTEGER NULL ,
stop_reason_source_concept_id INTEGER NULL
)
DISTRIBUTE ON (person_id)
;
@ -672,6 +686,7 @@ CREATE TABLE cohort
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL
)
DISTRIBUTE ON (subject_id)
;
@ -686,6 +701,7 @@ CREATE TABLE cohort_attribute
value_as_number NUMERIC NULL ,
value_as_concept_id INTEGER NULL
)
DISTRIBUTE ON (subject_id)
;
@ -700,6 +716,7 @@ CREATE TABLE drug_era
drug_exposure_count INTEGER NULL ,
gap_days INTEGER NULL
)
DISTRIBUTE ON (person_id)
;
@ -714,6 +731,7 @@ CREATE TABLE dose_era
dose_era_start_date DATE NOT NULL ,
dose_era_end_date DATE NOT NULL
)
DISTRIBUTE ON (person_id)
;
@ -727,4 +745,5 @@ CREATE TABLE condition_era
condition_era_end_date DATE NOT NULL ,
condition_occurrence_count INTEGER NULL
)
DISTRIBUTE ON (person_id)
;

View File

@ -0,0 +1,174 @@
/*********************************************************************************
# Copyright 2014 Observational Health Data Sciences and Informatics
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
********************************************************************************/
/************************
####### # # ####### ###### ##### ###### # # ####### ##### #####
# # ## ## # # # # # # # # ## ## # # # # # # # #### # # #### ##### ##### ## # # # ##### ####
# # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # #
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # #### # # # # # # # # # # ####
# # # # # # # # # # # # # # # ### # # # # # # # # # ##### ###### # # # # # #
# # # # # # # # # # # # # # # # # ### # # # # # # # ## # # # # # # # # # ## # # #
####### # # ####### # ##### ###### # # ## ##### ### ##### ##### #### # # #### # # # # # # # # # ####
netezza script to create the required indexes within OMOP common data model, version 5.3
last revised: 14-November-2017
author: Patrick Ryan, Clair Blacketer
description: These primary keys and indices are considered a minimal requirement to ensure adequate performance of analyses.
*************************/
/************************
*************************
*************************
*************************
Primary key constraints
*************************
*************************
*************************
************************/
/************************
Standardized vocabulary
************************/
ALTER TABLE concept ADD CONSTRAINT xpk_concept PRIMARY KEY (concept_id);
ALTER TABLE vocabulary ADD CONSTRAINT xpk_vocabulary PRIMARY KEY (vocabulary_id);
ALTER TABLE domain ADD CONSTRAINT xpk_domain PRIMARY KEY (domain_id);
ALTER TABLE concept_class ADD CONSTRAINT xpk_concept_class PRIMARY KEY (concept_class_id);
ALTER TABLE concept_relationship ADD CONSTRAINT xpk_concept_relationship PRIMARY KEY (concept_id_1,concept_id_2,relationship_id);
ALTER TABLE relationship ADD CONSTRAINT xpk_relationship PRIMARY KEY (relationship_id);
ALTER TABLE concept_ancestor ADD CONSTRAINT xpk_concept_ancestor PRIMARY KEY (ancestor_concept_id,descendant_concept_id);
ALTER TABLE source_to_concept_map ADD CONSTRAINT xpk_source_to_concept_map PRIMARY KEY (source_vocabulary_id,target_concept_id,source_code,valid_end_date);
ALTER TABLE drug_strength ADD CONSTRAINT xpk_drug_strength PRIMARY KEY (drug_concept_id, ingredient_concept_id);
ALTER TABLE cohort_definition ADD CONSTRAINT xpk_cohort_definition PRIMARY KEY (cohort_definition_id);
ALTER TABLE attribute_definition ADD CONSTRAINT xpk_attribute_definition PRIMARY KEY (attribute_definition_id);
/**************************
Standardized meta-data
***************************/
/************************
Standardized clinical data
************************/
/**PRIMARY KEY NONCLUSTERED constraints**/
ALTER TABLE person ADD CONSTRAINT xpk_person PRIMARY KEY ( person_id ) ;
ALTER TABLE observation_period ADD CONSTRAINT xpk_observation_period PRIMARY KEY ( observation_period_id ) ;
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 ) ;
ALTER TABLE procedure_occurrence ADD CONSTRAINT xpk_procedure_occurrence PRIMARY KEY ( procedure_occurrence_id ) ;
ALTER TABLE drug_exposure ADD CONSTRAINT xpk_drug_exposure PRIMARY KEY ( drug_exposure_id ) ;
ALTER TABLE device_exposure ADD CONSTRAINT xpk_device_exposure PRIMARY KEY ( device_exposure_id ) ;
ALTER TABLE condition_occurrence ADD CONSTRAINT xpk_condition_occurrence PRIMARY KEY ( condition_occurrence_id ) ;
ALTER TABLE measurement ADD CONSTRAINT xpk_measurement PRIMARY KEY ( measurement_id ) ;
ALTER TABLE note ADD CONSTRAINT xpk_note PRIMARY KEY ( note_id ) ;
ALTER TABLE note_nlp ADD CONSTRAINT xpk_note_nlp PRIMARY KEY ( note_nlp_id ) ;
ALTER TABLE observation ADD CONSTRAINT xpk_observation PRIMARY KEY ( observation_id ) ;
/************************
Standardized health system data
************************/
ALTER TABLE location ADD CONSTRAINT xpk_location PRIMARY KEY ( location_id ) ;
ALTER TABLE care_site ADD CONSTRAINT xpk_care_site PRIMARY KEY ( care_site_id ) ;
ALTER TABLE provider ADD CONSTRAINT xpk_provider PRIMARY KEY ( provider_id ) ;
/************************
Standardized health economics
************************/
ALTER TABLE payer_plan_period ADD CONSTRAINT xpk_payer_plan_period PRIMARY KEY ( payer_plan_period_id ) ;
ALTER TABLE cost ADD CONSTRAINT xpk_visit_cost PRIMARY KEY ( cost_id ) ;
/************************
Standardized derived elements
************************/
ALTER TABLE cohort ADD CONSTRAINT xpk_cohort PRIMARY KEY ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date ) ;
ALTER TABLE cohort_attribute ADD CONSTRAINT xpk_cohort_attribute PRIMARY KEY ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date, attribute_definition_id ) ;
ALTER TABLE drug_era ADD CONSTRAINT xpk_drug_era PRIMARY KEY ( drug_era_id ) ;
ALTER TABLE dose_era ADD CONSTRAINT xpk_dose_era PRIMARY KEY ( dose_era_id ) ;
ALTER TABLE condition_era ADD CONSTRAINT xpk_condition_era PRIMARY KEY ( condition_era_id ) ;