Updated DDLs

This commit is contained in:
Clair Blacketer 2021-08-19 15:04:43 -04:00
parent c1a4422dd1
commit 690c9edf40
26 changed files with 629 additions and 197 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -36,7 +36,7 @@ alter table @cdmDatabaseSchema.visit_occurrence add constraint fpk_visit_occurre
alter table @cdmDatabaseSchema.visit_occurrence add constraint fpk_visit_occurrence_admitted_from_concept_id foreign key (admitted_from_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.visit_occurrence add constraint fpk_visit_occurrence_discharge_to_concept_id foreign key (discharge_to_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.visit_occurrence add constraint fpk_visit_occurrence_discharged_to_concept_id foreign key (discharged_to_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.visit_occurrence add constraint fpk_visit_occurrence_preceding_visit_occurrence_id foreign key (preceding_visit_occurrence_id) references @cdmDatabaseSchema.visit_occurrence (visit_occurrence_id);
@ -54,11 +54,11 @@ alter table @cdmDatabaseSchema.visit_detail add constraint fpk_visit_detail_visi
alter table @cdmDatabaseSchema.visit_detail add constraint fpk_visit_detail_admitted_from_concept_id foreign key (admitted_from_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.visit_detail add constraint fpk_visit_detail_discharge_to_concept_id foreign key (discharge_to_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.visit_detail add constraint fpk_visit_detail_discharged_to_concept_id foreign key (discharged_to_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.visit_detail add constraint fpk_visit_detail_preceding_visit_detail_id foreign key (preceding_visit_detail_id) references @cdmDatabaseSchema.visit_detail (visit_detail_id);
alter table @cdmDatabaseSchema.visit_detail add constraint fpk_visit_detail_visit_detail_parent_id foreign key (visit_detail_parent_id) references @cdmDatabaseSchema.visit_detail (visit_detail_id);
alter table @cdmDatabaseSchema.visit_detail add constraint fpk_visit_detail_parent_visit_detail_id foreign key (parent_visit_detail_id) references @cdmDatabaseSchema.visit_detail (visit_detail_id);
alter table @cdmDatabaseSchema.visit_detail add constraint fpk_visit_detail_visit_occurrence_id foreign key (visit_occurrence_id) references @cdmDatabaseSchema.visit_occurrence (visit_occurrence_id);
@ -136,6 +136,10 @@ alter table @cdmDatabaseSchema.measurement add constraint fpk_measurement_visit_
alter table @cdmDatabaseSchema.measurement add constraint fpk_measurement_measurement_source_concept_id foreign key (measurement_source_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.measurement add constraint fpk_measurement_unit_source_concept_id foreign key (unit_source_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.measurement add constraint fpk_measurement_meas_event_field_concept_id foreign key (meas_event_field_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.observation add constraint fpk_observation_person_id foreign key (person_id) references @cdmDatabaseSchema.person (person_id);
alter table @cdmDatabaseSchema.observation add constraint fpk_observation_observation_concept_id foreign key (observation_concept_id) references @cdmDatabaseSchema.concept (concept_id);
@ -156,6 +160,8 @@ alter table @cdmDatabaseSchema.observation add constraint fpk_observation_visit_
alter table @cdmDatabaseSchema.observation add constraint fpk_observation_observation_source_concept_id foreign key (observation_source_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.observation add constraint fpk_observation_obs_event_field_concept_id foreign key (obs_event_field_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.death add constraint fpk_death_person_id foreign key (person_id) references @cdmDatabaseSchema.person (person_id);
alter table @cdmDatabaseSchema.death add constraint fpk_death_death_type_concept_id foreign key (death_type_concept_id) references @cdmDatabaseSchema.concept (concept_id);
@ -166,6 +172,8 @@ alter table @cdmDatabaseSchema.death add constraint fpk_death_cause_source_conce
alter table @cdmDatabaseSchema.note add constraint fpk_note_person_id foreign key (person_id) references @cdmDatabaseSchema.person (person_id);
alter table @cdmDatabaseSchema.note add constraint fpk_note_note_event_field_concept_id foreign key (note_event_field_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.note add constraint fpk_note_note_type_concept_id foreign key (note_type_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.note add constraint fpk_note_note_class_concept_id foreign key (note_class_concept_id) references @cdmDatabaseSchema.concept (concept_id);
@ -260,6 +268,20 @@ alter table @cdmDatabaseSchema.dose_era add constraint fpk_dose_era_unit_concept
alter table @cdmDatabaseSchema.condition_era add constraint fpk_condition_era_condition_concept_id foreign key (condition_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.episode add constraint fpk_episode_person_id foreign key (person_id) references @cdmDatabaseSchema.person (person_id);
alter table @cdmDatabaseSchema.episode add constraint fpk_episode_episode_concept_id foreign key (episode_concept_id) references @cdmDatabaseSchema. ();
alter table @cdmDatabaseSchema.episode add constraint fpk_episode_episode_object_concept_id foreign key (episode_object_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.episode add constraint fpk_episode_episode_type_concept_id foreign key (episode_type_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.episode add constraint fpk_episode_episode_source_concept_id foreign key (episode_source_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.episode_event add constraint fpk_episode_event_episode_id foreign key (episode_id) references @cdmDatabaseSchema.episode (episode_id);
alter table @cdmDatabaseSchema.episode_event add constraint fpk_episode_event_episode_event_field_concept_id foreign key (episode_event_field_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.metadata add constraint fpk_metadata_metadata_concept_id foreign key (metadata_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.metadata add constraint fpk_metadata_metadata_type_concept_id foreign key (metadata_type_concept_id) references @cdmDatabaseSchema.concept (concept_id);
@ -313,5 +335,3 @@ alter table @cdmDatabaseSchema.drug_strength add constraint fpk_drug_strength_de
alter table @cdmDatabaseSchema.cohort_definition add constraint fpk_cohort_definition_definition_type_concept_id foreign key (definition_type_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.cohort_definition add constraint fpk_cohort_definition_subject_concept_id foreign key (subject_concept_id) references @cdmDatabaseSchema.concept (concept_id);
alter table @cdmDatabaseSchema.attribute_definition add constraint fpk_attribute_definition_attribute_type_concept_id foreign key (attribute_type_concept_id) references @cdmDatabaseSchema.concept (concept_id);

View File

@ -45,8 +45,8 @@ create table @cdmDatabaseSchema.visit_occurrence (
visit_source_concept_id INT64,
admitted_from_concept_id INT64,
admitted_from_source_value STRING,
discharge_to_concept_id INT64,
discharge_to_source_value STRING,
discharged_to_concept_id INT64,
discharged_to_source_value STRING,
preceding_visit_occurrence_id INT64 );
--HINT DISTRIBUTE ON KEY (person_id)
@ -63,12 +63,12 @@ create table @cdmDatabaseSchema.visit_detail (
care_site_id INT64,
visit_detail_source_value STRING,
visit_detail_source_concept_id INT64,
admitted_from_source_value STRING,
admitted_from_concept_id INT64,
discharge_to_source_value STRING,
discharge_to_concept_id INT64,
admitted_from_source_value STRING,
discharged_to_source_value STRING,
discharged_to_concept_id INT64,
preceding_visit_detail_id INT64,
visit_detail_parent_id INT64,
parent_visit_detail_id INT64,
visit_occurrence_id INT64 not null );
--HINT DISTRIBUTE ON KEY (person_id)
@ -178,7 +178,10 @@ create table @cdmDatabaseSchema.measurement (
measurement_source_value STRING,
measurement_source_concept_id INT64,
unit_source_value STRING,
value_source_value STRING );
unit_source_concept_id INT64,
value_source_value STRING,
measurement_event_id INT64,
meas_event_field_concept_id INT64 );
--HINT DISTRIBUTE ON KEY (person_id)
create table @cdmDatabaseSchema.observation (
@ -200,7 +203,9 @@ create table @cdmDatabaseSchema.observation (
observation_source_concept_id INT64,
unit_source_value STRING,
qualifier_source_value STRING,
value_source_value STRING );
value_source_value STRING,
observation_event_id INT64,
obs_event_field_concept_id INT64 );
--HINT DISTRIBUTE ON KEY (person_id)
create table @cdmDatabaseSchema.death (
@ -216,6 +221,8 @@ create table @cdmDatabaseSchema.death (
create table @cdmDatabaseSchema.note (
note_id INT64 not null,
person_id INT64 not null,
note_event_id INT64,
note_event_field_concept_id INT64,
note_date date not null,
note_datetime datetime null,
note_type_concept_id INT64 not null,
@ -386,13 +393,37 @@ create table @cdmDatabaseSchema.condition_era (
condition_era_end_date datetime not null,
condition_occurrence_count INT64 );
--HINT DISTRIBUTE ON KEY (person_id)
create table @cdmDatabaseSchema.episode (
episode_id INT64 not null,
person_id INT64 not null,
episode_concept_id INT64 not null,
episode_start_date date not null,
episode_start_datetime datetime null,
episode_end_date date null,
episode_end_datetime datetime null,
episode_parent_id INT64,
episode_number INT64,
episode_object_concept_id INT64 not null,
episode_type_concept_id INT64 not null,
episode_source_value STRING,
episode_source_concept_id INT64 );
--HINT DISTRIBUTE ON RANDOM
create table @cdmDatabaseSchema.episode_event (
episode_id INT64 not null,
event_id INT64 not null,
episode_event_field_concept_id INT64 not null );
--HINT DISTRIBUTE ON RANDOM
create table @cdmDatabaseSchema.metadata (
metadata_id INT64 not null,
metadata_concept_id INT64 not null,
metadata_type_concept_id INT64 not null,
name STRING not null,
value_as_string STRING,
value_as_concept_id INT64,
value_as_number FLOAT64 null,
metadata_date date null,
metadata_datetime datetime null );
@ -501,6 +532,13 @@ create table @cdmDatabaseSchema.drug_strength (
valid_end_date date not null,
invalid_reason STRING );
--HINT DISTRIBUTE ON RANDOM
create table @cdmDatabaseSchema.cohort (
cohort_definition_id INT64 not null,
subject_id INT64 not null,
cohort_start_date date not null,
cohort_end_date date not null );
--HINT DISTRIBUTE ON RANDOM
create table @cdmDatabaseSchema.cohort_definition (
cohort_definition_id INT64 not null,
@ -510,11 +548,3 @@ create table @cdmDatabaseSchema.cohort_definition (
cohort_definition_syntax STRING,
subject_concept_id INT64 not null,
cohort_initiation_date date null );
--HINT DISTRIBUTE ON RANDOM
create table @cdmDatabaseSchema.attribute_definition (
attribute_definition_id INT64 not null,
attribute_name STRING not null,
attribute_description STRING,
attribute_type_concept_id INT64 not null,
attribute_syntax STRING );

View File

@ -42,6 +42,10 @@ alter table @cdmDatabaseSchema.dose_era add constraint xpk_dose_era primary key
alter table @cdmDatabaseSchema.condition_era add constraint xpk_condition_era primary key nonclustered (condition_era_id);
alter table @cdmDatabaseSchema.episode add constraint xpk_episode primary key nonclustered (episode_id);
alter table @cdmDatabaseSchema.metadata add constraint xpk_metadata primary key nonclustered (metadata_id);
alter table @cdmDatabaseSchema.concept add constraint xpk_concept primary key nonclustered (concept_id);
alter table @cdmDatabaseSchema.vocabulary add constraint xpk_vocabulary primary key nonclustered (vocabulary_id);

View File

@ -36,7 +36,7 @@ ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRE
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_admitted_from_concept_id FOREIGN KEY (admitted_from_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_discharge_to_concept_id FOREIGN KEY (discharge_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_discharged_to_concept_id FOREIGN KEY (discharged_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_preceding_visit_occurrence_id FOREIGN KEY (preceding_visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID);
@ -54,11 +54,11 @@ ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visi
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_admitted_from_concept_id FOREIGN KEY (admitted_from_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_discharge_to_concept_id FOREIGN KEY (discharge_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_discharged_to_concept_id FOREIGN KEY (discharged_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_preceding_visit_detail_id FOREIGN KEY (preceding_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visit_detail_parent_id FOREIGN KEY (visit_detail_parent_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_parent_visit_detail_id FOREIGN KEY (parent_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID);
@ -136,6 +136,10 @@ ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_visit_
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_measurement_source_concept_id FOREIGN KEY (measurement_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_unit_source_concept_id FOREIGN KEY (unit_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_meas_event_field_concept_id FOREIGN KEY (meas_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_observation_concept_id FOREIGN KEY (observation_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -156,6 +160,8 @@ ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_visit_
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_observation_source_concept_id FOREIGN KEY (observation_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_obs_event_field_concept_id FOREIGN KEY (obs_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_death_type_concept_id FOREIGN KEY (death_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -166,6 +172,8 @@ ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_cause_source_conce
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_event_field_concept_id FOREIGN KEY (note_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_type_concept_id FOREIGN KEY (note_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_class_concept_id FOREIGN KEY (note_class_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -260,6 +268,20 @@ ALTER TABLE @cdmDatabaseSchema.DOSE_ERA ADD CONSTRAINT fpk_DOSE_ERA_unit_concept
ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT fpk_CONDITION_ERA_condition_concept_id FOREIGN KEY (condition_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_concept_id FOREIGN KEY (episode_concept_id) REFERENCES @cdmDatabaseSchema. ();
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_object_concept_id FOREIGN KEY (episode_object_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_type_concept_id FOREIGN KEY (episode_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_source_concept_id FOREIGN KEY (episode_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE_EVENT ADD CONSTRAINT fpk_EPISODE_EVENT_episode_id FOREIGN KEY (episode_id) REFERENCES @cdmDatabaseSchema.EPISODE (EPISODE_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE_EVENT ADD CONSTRAINT fpk_EPISODE_EVENT_episode_event_field_concept_id FOREIGN KEY (episode_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT fpk_METADATA_metadata_concept_id FOREIGN KEY (metadata_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT fpk_METADATA_metadata_type_concept_id FOREIGN KEY (metadata_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -313,5 +335,3 @@ ALTER TABLE @cdmDatabaseSchema.DRUG_STRENGTH ADD CONSTRAINT fpk_DRUG_STRENGTH_de
ALTER TABLE @cdmDatabaseSchema.COHORT_DEFINITION ADD CONSTRAINT fpk_COHORT_DEFINITION_definition_type_concept_id FOREIGN KEY (definition_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.COHORT_DEFINITION ADD CONSTRAINT fpk_COHORT_DEFINITION_subject_concept_id FOREIGN KEY (subject_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.ATTRIBUTE_DEFINITION ADD CONSTRAINT fpk_ATTRIBUTE_DEFINITION_attribute_type_concept_id FOREIGN KEY (attribute_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);

View File

@ -45,8 +45,8 @@ CREATE TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE (
visit_source_concept_id integer NULL,
admitted_from_concept_id integer NULL,
admitted_from_source_value VARCHAR(50),
discharge_to_concept_id integer NULL,
discharge_to_source_value VARCHAR(50),
discharged_to_concept_id integer NULL,
discharged_to_source_value VARCHAR(50),
preceding_visit_occurrence_id integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
@ -63,12 +63,12 @@ CREATE TABLE @cdmDatabaseSchema.VISIT_DETAIL (
care_site_id integer NULL,
visit_detail_source_value VARCHAR(50),
visit_detail_source_concept_id Integer NULL,
admitted_from_source_value VARCHAR(50),
admitted_from_concept_id Integer NULL,
discharge_to_source_value VARCHAR(50),
discharge_to_concept_id integer NULL,
admitted_from_source_value VARCHAR(50),
discharged_to_source_value VARCHAR(50),
discharged_to_concept_id integer NULL,
preceding_visit_detail_id integer NULL,
visit_detail_parent_id integer NULL,
parent_visit_detail_id integer NULL,
visit_occurrence_id INT );
--HINT DISTRIBUTE ON KEY (person_id)
@ -178,7 +178,10 @@ CREATE TABLE @cdmDatabaseSchema.MEASUREMENT (
measurement_source_value VARCHAR(50),
measurement_source_concept_id integer NULL,
unit_source_value VARCHAR(50),
value_source_value VARCHAR(50) );
unit_source_concept_id integer NULL,
value_source_value VARCHAR(50),
measurement_event_id BIGINT,
meas_event_field_concept_id integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
CREATE TABLE @cdmDatabaseSchema.OBSERVATION (
@ -200,7 +203,9 @@ CREATE TABLE @cdmDatabaseSchema.OBSERVATION (
observation_source_concept_id integer NULL,
unit_source_value VARCHAR(50),
qualifier_source_value VARCHAR(50),
value_source_value VARCHAR(50) );
value_source_value VARCHAR(50),
observation_event_id BIGINT,
obs_event_field_concept_id integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
CREATE TABLE @cdmDatabaseSchema.DEATH (
@ -216,6 +221,8 @@ CREATE TABLE @cdmDatabaseSchema.DEATH (
CREATE TABLE @cdmDatabaseSchema.NOTE (
note_id INT,
person_id INT,
note_event_id BIGINT,
note_event_field_concept_id integer NULL,
note_date TIMESTAMP,
note_datetime TIMESTAMP,
note_type_concept_id INT,
@ -386,13 +393,37 @@ CREATE TABLE @cdmDatabaseSchema.CONDITION_ERA (
condition_era_end_date TIMESTAMP,
condition_occurrence_count integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
CREATE TABLE @cdmDatabaseSchema.EPISODE (
episode_id BIGINT,
person_id BIGINT,
episode_concept_id INT,
episode_start_date TIMESTAMP,
episode_start_datetime TIMESTAMP,
episode_end_date TIMESTAMP,
episode_end_datetime TIMESTAMP,
episode_parent_id BIGINT,
episode_number integer NULL,
episode_object_concept_id INT,
episode_type_concept_id INT,
episode_source_value VARCHAR(50),
episode_source_concept_id integer NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.EPISODE_EVENT (
episode_id BIGINT,
event_id BIGINT,
episode_event_field_concept_id INT );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.METADATA (
metadata_id INT,
metadata_concept_id INT,
metadata_type_concept_id INT,
name VARCHAR(250),
value_as_string VARCHAR(250),
value_as_concept_id integer NULL,
value_as_number FLOAT,
metadata_date TIMESTAMP,
metadata_datetime TIMESTAMP );
@ -501,6 +532,13 @@ CREATE TABLE @cdmDatabaseSchema.DRUG_STRENGTH (
valid_end_date TIMESTAMP,
invalid_reason VARCHAR(1) );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.COHORT (
cohort_definition_id INT,
subject_id INT,
cohort_start_date TIMESTAMP,
cohort_end_date TIMESTAMP );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.COHORT_DEFINITION (
cohort_definition_id INT,
@ -510,11 +548,3 @@ CREATE TABLE @cdmDatabaseSchema.COHORT_DEFINITION (
cohort_definition_syntax VARCHAR(MAX),
subject_concept_id INT,
cohort_initiation_date TIMESTAMP );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.ATTRIBUTE_DEFINITION (
attribute_definition_id INT,
attribute_name VARCHAR(255),
attribute_description VARCHAR(MAX),
attribute_type_concept_id INT,
attribute_syntax VARCHAR(MAX) );

View File

@ -42,6 +42,10 @@ ALTER TABLE @cdmDatabaseSchema.DOSE_ERA ADD CONSTRAINT xpk_DOSE_ERA PRIMARY KEY
ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT xpk_CONDITION_ERA PRIMARY KEY NONCLUSTERED (condition_era_id);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT xpk_EPISODE PRIMARY KEY NONCLUSTERED (episode_id);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT xpk_METADATA PRIMARY KEY NONCLUSTERED (metadata_id);
ALTER TABLE @cdmDatabaseSchema.CONCEPT ADD CONSTRAINT xpk_CONCEPT PRIMARY KEY NONCLUSTERED (concept_id);
ALTER TABLE @cdmDatabaseSchema.VOCABULARY ADD CONSTRAINT xpk_VOCABULARY PRIMARY KEY NONCLUSTERED (vocabulary_id);

View File

@ -36,7 +36,7 @@ ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRE
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_admitted_from_concept_id FOREIGN KEY (admitted_from_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_discharge_to_concept_id FOREIGN KEY (discharge_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_discharged_to_concept_id FOREIGN KEY (discharged_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_preceding_visit_occurrence_id FOREIGN KEY (preceding_visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID);
@ -54,11 +54,11 @@ ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visi
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_admitted_from_concept_id FOREIGN KEY (admitted_from_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_discharge_to_concept_id FOREIGN KEY (discharge_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_discharged_to_concept_id FOREIGN KEY (discharged_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_preceding_visit_detail_id FOREIGN KEY (preceding_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visit_detail_parent_id FOREIGN KEY (visit_detail_parent_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_parent_visit_detail_id FOREIGN KEY (parent_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID);
@ -136,6 +136,10 @@ ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_visit_
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_measurement_source_concept_id FOREIGN KEY (measurement_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_unit_source_concept_id FOREIGN KEY (unit_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_meas_event_field_concept_id FOREIGN KEY (meas_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_observation_concept_id FOREIGN KEY (observation_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -156,6 +160,8 @@ ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_visit_
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_observation_source_concept_id FOREIGN KEY (observation_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_obs_event_field_concept_id FOREIGN KEY (obs_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_death_type_concept_id FOREIGN KEY (death_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -166,6 +172,8 @@ ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_cause_source_conce
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_event_field_concept_id FOREIGN KEY (note_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_type_concept_id FOREIGN KEY (note_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_class_concept_id FOREIGN KEY (note_class_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -260,6 +268,20 @@ ALTER TABLE @cdmDatabaseSchema.DOSE_ERA ADD CONSTRAINT fpk_DOSE_ERA_unit_concept
ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT fpk_CONDITION_ERA_condition_concept_id FOREIGN KEY (condition_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_concept_id FOREIGN KEY (episode_concept_id) REFERENCES @cdmDatabaseSchema. ();
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_object_concept_id FOREIGN KEY (episode_object_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_type_concept_id FOREIGN KEY (episode_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_source_concept_id FOREIGN KEY (episode_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE_EVENT ADD CONSTRAINT fpk_EPISODE_EVENT_episode_id FOREIGN KEY (episode_id) REFERENCES @cdmDatabaseSchema.EPISODE (EPISODE_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE_EVENT ADD CONSTRAINT fpk_EPISODE_EVENT_episode_event_field_concept_id FOREIGN KEY (episode_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT fpk_METADATA_metadata_concept_id FOREIGN KEY (metadata_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT fpk_METADATA_metadata_type_concept_id FOREIGN KEY (metadata_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -313,5 +335,3 @@ ALTER TABLE @cdmDatabaseSchema.DRUG_STRENGTH ADD CONSTRAINT fpk_DRUG_STRENGTH_de
ALTER TABLE @cdmDatabaseSchema.COHORT_DEFINITION ADD CONSTRAINT fpk_COHORT_DEFINITION_definition_type_concept_id FOREIGN KEY (definition_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.COHORT_DEFINITION ADD CONSTRAINT fpk_COHORT_DEFINITION_subject_concept_id FOREIGN KEY (subject_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.ATTRIBUTE_DEFINITION ADD CONSTRAINT fpk_ATTRIBUTE_DEFINITION_attribute_type_concept_id FOREIGN KEY (attribute_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);

View File

@ -45,8 +45,8 @@ CREATE TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE (
visit_source_concept_id integer NULL,
admitted_from_concept_id integer NULL,
admitted_from_source_value varchar(50) NULL,
discharge_to_concept_id integer NULL,
discharge_to_source_value varchar(50) NULL,
discharged_to_concept_id integer NULL,
discharged_to_source_value varchar(50) NULL,
preceding_visit_occurrence_id integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
@ -63,12 +63,12 @@ CREATE TABLE @cdmDatabaseSchema.VISIT_DETAIL (
care_site_id integer NULL,
visit_detail_source_value varchar(50) NULL,
visit_detail_source_concept_id Integer NULL,
admitted_from_source_value Varchar(50) NULL,
admitted_from_concept_id Integer NULL,
discharge_to_source_value Varchar(50) NULL,
discharge_to_concept_id integer NULL,
admitted_from_source_value Varchar(50) NULL,
discharged_to_source_value Varchar(50) NULL,
discharged_to_concept_id integer NULL,
preceding_visit_detail_id integer NULL,
visit_detail_parent_id integer NULL,
parent_visit_detail_id integer NULL,
visit_occurrence_id integer NOT NULL );
--HINT DISTRIBUTE ON KEY (person_id)
@ -178,7 +178,10 @@ CREATE TABLE @cdmDatabaseSchema.MEASUREMENT (
measurement_source_value varchar(50) NULL,
measurement_source_concept_id integer NULL,
unit_source_value varchar(50) NULL,
value_source_value varchar(50) NULL );
unit_source_concept_id integer NULL,
value_source_value varchar(50) NULL,
measurement_event_id bigint NULL,
meas_event_field_concept_id integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
CREATE TABLE @cdmDatabaseSchema.OBSERVATION (
@ -200,7 +203,9 @@ CREATE TABLE @cdmDatabaseSchema.OBSERVATION (
observation_source_concept_id integer NULL,
unit_source_value varchar(50) NULL,
qualifier_source_value varchar(50) NULL,
value_source_value varchar(50) NULL );
value_source_value varchar(50) NULL,
observation_event_id bigint NULL,
obs_event_field_concept_id integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
CREATE TABLE @cdmDatabaseSchema.DEATH (
@ -216,6 +221,8 @@ CREATE TABLE @cdmDatabaseSchema.DEATH (
CREATE TABLE @cdmDatabaseSchema.NOTE (
note_id integer NOT NULL,
person_id integer NOT NULL,
note_event_id bigint NULL,
note_event_field_concept_id integer NULL,
note_date date NOT NULL,
note_datetime TIMESTAMP NULL,
note_type_concept_id integer NOT NULL,
@ -386,13 +393,37 @@ CREATE TABLE @cdmDatabaseSchema.CONDITION_ERA (
condition_era_end_date TIMESTAMP NOT NULL,
condition_occurrence_count integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
CREATE TABLE @cdmDatabaseSchema.EPISODE (
episode_id bigint NOT NULL,
person_id bigint NOT NULL,
episode_concept_id integer NOT NULL,
episode_start_date date NOT NULL,
episode_start_datetime TIMESTAMP NULL,
episode_end_date date NULL,
episode_end_datetime TIMESTAMP NULL,
episode_parent_id bigint NULL,
episode_number integer NULL,
episode_object_concept_id integer NOT NULL,
episode_type_concept_id integer NOT NULL,
episode_source_value varchar(50) NULL,
episode_source_concept_id integer NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.EPISODE_EVENT (
episode_id bigint NOT NULL,
event_id bigint NOT NULL,
episode_event_field_concept_id integer NOT NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.METADATA (
metadata_id integer NOT NULL,
metadata_concept_id integer NOT NULL,
metadata_type_concept_id integer NOT NULL,
name varchar(250) NOT NULL,
value_as_string varchar(250) NULL,
value_as_concept_id integer NULL,
value_as_number FLOAT(6) NULL,
metadata_date date NULL,
metadata_datetime TIMESTAMP NULL );
@ -501,6 +532,13 @@ CREATE TABLE @cdmDatabaseSchema.DRUG_STRENGTH (
valid_end_date date NOT NULL,
invalid_reason varchar(1) NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.COHORT (
cohort_definition_id integer NOT NULL,
subject_id integer NOT NULL,
cohort_start_date date NOT NULL,
cohort_end_date date NOT NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.COHORT_DEFINITION (
cohort_definition_id integer NOT NULL,
@ -510,11 +548,3 @@ CREATE TABLE @cdmDatabaseSchema.COHORT_DEFINITION (
cohort_definition_syntax VARCHAR(1000) NULL,
subject_concept_id integer NOT NULL,
cohort_initiation_date date NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.ATTRIBUTE_DEFINITION (
attribute_definition_id integer NOT NULL,
attribute_name varchar(255) NOT NULL,
attribute_description VARCHAR(1000) NULL,
attribute_type_concept_id integer NOT NULL,
attribute_syntax VARCHAR(1000) NULL );

View File

@ -42,6 +42,10 @@ ALTER TABLE @cdmDatabaseSchema.DOSE_ERA ADD CONSTRAINT xpk_DOSE_ERA PRIMARY KEY
ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT xpk_CONDITION_ERA PRIMARY KEY (condition_era_id);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT xpk_EPISODE PRIMARY KEY (episode_id);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT xpk_METADATA PRIMARY KEY (metadata_id);
ALTER TABLE @cdmDatabaseSchema.CONCEPT ADD CONSTRAINT xpk_CONCEPT PRIMARY KEY (concept_id);
ALTER TABLE @cdmDatabaseSchema.VOCABULARY ADD CONSTRAINT xpk_VOCABULARY PRIMARY KEY (vocabulary_id);

View File

@ -36,7 +36,7 @@ ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRE
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_admitted_from_concept_id FOREIGN KEY (admitted_from_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_discharge_to_concept_id FOREIGN KEY (discharge_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_discharged_to_concept_id FOREIGN KEY (discharged_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_preceding_visit_occurrence_id FOREIGN KEY (preceding_visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID);
@ -54,11 +54,11 @@ ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visi
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_admitted_from_concept_id FOREIGN KEY (admitted_from_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_discharge_to_concept_id FOREIGN KEY (discharge_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_discharged_to_concept_id FOREIGN KEY (discharged_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_preceding_visit_detail_id FOREIGN KEY (preceding_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visit_detail_parent_id FOREIGN KEY (visit_detail_parent_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_parent_visit_detail_id FOREIGN KEY (parent_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID);
@ -136,6 +136,10 @@ ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_visit_
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_measurement_source_concept_id FOREIGN KEY (measurement_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_unit_source_concept_id FOREIGN KEY (unit_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_meas_event_field_concept_id FOREIGN KEY (meas_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_observation_concept_id FOREIGN KEY (observation_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -156,6 +160,8 @@ ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_visit_
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_observation_source_concept_id FOREIGN KEY (observation_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_obs_event_field_concept_id FOREIGN KEY (obs_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_death_type_concept_id FOREIGN KEY (death_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -166,6 +172,8 @@ ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_cause_source_conce
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_event_field_concept_id FOREIGN KEY (note_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_type_concept_id FOREIGN KEY (note_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_class_concept_id FOREIGN KEY (note_class_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -260,6 +268,20 @@ ALTER TABLE @cdmDatabaseSchema.DOSE_ERA ADD CONSTRAINT fpk_DOSE_ERA_unit_concept
ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT fpk_CONDITION_ERA_condition_concept_id FOREIGN KEY (condition_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_concept_id FOREIGN KEY (episode_concept_id) REFERENCES @cdmDatabaseSchema. ();
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_object_concept_id FOREIGN KEY (episode_object_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_type_concept_id FOREIGN KEY (episode_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_source_concept_id FOREIGN KEY (episode_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE_EVENT ADD CONSTRAINT fpk_EPISODE_EVENT_episode_id FOREIGN KEY (episode_id) REFERENCES @cdmDatabaseSchema.EPISODE (EPISODE_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE_EVENT ADD CONSTRAINT fpk_EPISODE_EVENT_episode_event_field_concept_id FOREIGN KEY (episode_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT fpk_METADATA_metadata_concept_id FOREIGN KEY (metadata_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT fpk_METADATA_metadata_type_concept_id FOREIGN KEY (metadata_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -313,5 +335,3 @@ ALTER TABLE @cdmDatabaseSchema.DRUG_STRENGTH ADD CONSTRAINT fpk_DRUG_STRENGTH_de
ALTER TABLE @cdmDatabaseSchema.COHORT_DEFINITION ADD CONSTRAINT fpk_COHORT_DEFINITION_definition_type_concept_id FOREIGN KEY (definition_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.COHORT_DEFINITION ADD CONSTRAINT fpk_COHORT_DEFINITION_subject_concept_id FOREIGN KEY (subject_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.ATTRIBUTE_DEFINITION ADD CONSTRAINT fpk_ATTRIBUTE_DEFINITION_attribute_type_concept_id FOREIGN KEY (attribute_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);

View File

@ -45,8 +45,8 @@ CREATE TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE (
visit_source_concept_id integer NULL,
admitted_from_concept_id integer NULL,
admitted_from_source_value varchar(50) NULL,
discharge_to_concept_id integer NULL,
discharge_to_source_value varchar(50) NULL,
discharged_to_concept_id integer NULL,
discharged_to_source_value varchar(50) NULL,
preceding_visit_occurrence_id integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
@ -63,12 +63,12 @@ CREATE TABLE @cdmDatabaseSchema.VISIT_DETAIL (
care_site_id integer NULL,
visit_detail_source_value varchar(50) NULL,
visit_detail_source_concept_id Integer NULL,
admitted_from_source_value Varchar(50) NULL,
admitted_from_concept_id Integer NULL,
discharge_to_source_value Varchar(50) NULL,
discharge_to_concept_id integer NULL,
admitted_from_source_value Varchar(50) NULL,
discharged_to_source_value Varchar(50) NULL,
discharged_to_concept_id integer NULL,
preceding_visit_detail_id integer NULL,
visit_detail_parent_id integer NULL,
parent_visit_detail_id integer NULL,
visit_occurrence_id integer NOT NULL );
--HINT DISTRIBUTE ON KEY (person_id)
@ -178,7 +178,10 @@ CREATE TABLE @cdmDatabaseSchema.MEASUREMENT (
measurement_source_value varchar(50) NULL,
measurement_source_concept_id integer NULL,
unit_source_value varchar(50) NULL,
value_source_value varchar(50) NULL );
unit_source_concept_id integer NULL,
value_source_value varchar(50) NULL,
measurement_event_id NUMBER(19) NULL,
meas_event_field_concept_id integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
CREATE TABLE @cdmDatabaseSchema.OBSERVATION (
@ -200,7 +203,9 @@ CREATE TABLE @cdmDatabaseSchema.OBSERVATION (
observation_source_concept_id integer NULL,
unit_source_value varchar(50) NULL,
qualifier_source_value varchar(50) NULL,
value_source_value varchar(50) NULL );
value_source_value varchar(50) NULL,
observation_event_id NUMBER(19) NULL,
obs_event_field_concept_id integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
CREATE TABLE @cdmDatabaseSchema.DEATH (
@ -216,6 +221,8 @@ CREATE TABLE @cdmDatabaseSchema.DEATH (
CREATE TABLE @cdmDatabaseSchema.NOTE (
note_id integer NOT NULL,
person_id integer NOT NULL,
note_event_id NUMBER(19) NULL,
note_event_field_concept_id integer NULL,
note_date date NOT NULL,
note_datetime TIMESTAMP NULL,
note_type_concept_id integer NOT NULL,
@ -386,13 +393,37 @@ CREATE TABLE @cdmDatabaseSchema.CONDITION_ERA (
condition_era_end_date TIMESTAMP NOT NULL,
condition_occurrence_count integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
CREATE TABLE @cdmDatabaseSchema.EPISODE (
episode_id NUMBER(19) NOT NULL,
person_id NUMBER(19) NOT NULL,
episode_concept_id integer NOT NULL,
episode_start_date date NOT NULL,
episode_start_datetime TIMESTAMP NULL,
episode_end_date date NULL,
episode_end_datetime TIMESTAMP NULL,
episode_parent_id NUMBER(19) NULL,
episode_number integer NULL,
episode_object_concept_id integer NOT NULL,
episode_type_concept_id integer NOT NULL,
episode_source_value varchar(50) NULL,
episode_source_concept_id integer NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.EPISODE_EVENT (
episode_id NUMBER(19) NOT NULL,
event_id NUMBER(19) NOT NULL,
episode_event_field_concept_id integer NOT NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.METADATA (
metadata_id integer NOT NULL,
metadata_concept_id integer NOT NULL,
metadata_type_concept_id integer NOT NULL,
name varchar(250) NOT NULL,
value_as_string varchar(250) NULL,
value_as_concept_id integer NULL,
value_as_number float NULL,
metadata_date date NULL,
metadata_datetime TIMESTAMP NULL );
@ -501,6 +532,13 @@ CREATE TABLE @cdmDatabaseSchema.DRUG_STRENGTH (
valid_end_date date NOT NULL,
invalid_reason varchar(1) NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.COHORT (
cohort_definition_id integer NOT NULL,
subject_id integer NOT NULL,
cohort_start_date date NOT NULL,
cohort_end_date date NOT NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.COHORT_DEFINITION (
cohort_definition_id integer NOT NULL,
@ -510,11 +548,3 @@ CREATE TABLE @cdmDatabaseSchema.COHORT_DEFINITION (
cohort_definition_syntax CLOB NULL,
subject_concept_id integer NOT NULL,
cohort_initiation_date date NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.ATTRIBUTE_DEFINITION (
attribute_definition_id integer NOT NULL,
attribute_name varchar(255) NOT NULL,
attribute_description CLOB NULL,
attribute_type_concept_id integer NOT NULL,
attribute_syntax CLOB NULL );

View File

@ -42,6 +42,10 @@ ALTER TABLE @cdmDatabaseSchema.DOSE_ERA ADD CONSTRAINT xpk_DOSE_ERA PRIMARY KEY
ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT xpk_CONDITION_ERA PRIMARY KEY (condition_era_id);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT xpk_EPISODE PRIMARY KEY (episode_id);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT xpk_METADATA PRIMARY KEY (metadata_id);
ALTER TABLE @cdmDatabaseSchema.CONCEPT ADD CONSTRAINT xpk_CONCEPT PRIMARY KEY (concept_id);
ALTER TABLE @cdmDatabaseSchema.VOCABULARY ADD CONSTRAINT xpk_VOCABULARY PRIMARY KEY (vocabulary_id);

View File

@ -36,7 +36,7 @@ ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRE
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_admitted_from_concept_id FOREIGN KEY (admitted_from_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_discharge_to_concept_id FOREIGN KEY (discharge_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_discharged_to_concept_id FOREIGN KEY (discharged_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_preceding_visit_occurrence_id FOREIGN KEY (preceding_visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID);
@ -54,11 +54,11 @@ ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visi
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_admitted_from_concept_id FOREIGN KEY (admitted_from_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_discharge_to_concept_id FOREIGN KEY (discharge_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_discharged_to_concept_id FOREIGN KEY (discharged_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_preceding_visit_detail_id FOREIGN KEY (preceding_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visit_detail_parent_id FOREIGN KEY (visit_detail_parent_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_parent_visit_detail_id FOREIGN KEY (parent_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID);
@ -136,6 +136,10 @@ ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_visit_
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_measurement_source_concept_id FOREIGN KEY (measurement_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_unit_source_concept_id FOREIGN KEY (unit_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_meas_event_field_concept_id FOREIGN KEY (meas_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_observation_concept_id FOREIGN KEY (observation_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -156,6 +160,8 @@ ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_visit_
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_observation_source_concept_id FOREIGN KEY (observation_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_obs_event_field_concept_id FOREIGN KEY (obs_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_death_type_concept_id FOREIGN KEY (death_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -166,6 +172,8 @@ ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_cause_source_conce
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_event_field_concept_id FOREIGN KEY (note_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_type_concept_id FOREIGN KEY (note_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_class_concept_id FOREIGN KEY (note_class_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -260,6 +268,20 @@ ALTER TABLE @cdmDatabaseSchema.DOSE_ERA ADD CONSTRAINT fpk_DOSE_ERA_unit_concept
ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT fpk_CONDITION_ERA_condition_concept_id FOREIGN KEY (condition_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_concept_id FOREIGN KEY (episode_concept_id) REFERENCES @cdmDatabaseSchema. ();
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_object_concept_id FOREIGN KEY (episode_object_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_type_concept_id FOREIGN KEY (episode_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_source_concept_id FOREIGN KEY (episode_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE_EVENT ADD CONSTRAINT fpk_EPISODE_EVENT_episode_id FOREIGN KEY (episode_id) REFERENCES @cdmDatabaseSchema.EPISODE (EPISODE_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE_EVENT ADD CONSTRAINT fpk_EPISODE_EVENT_episode_event_field_concept_id FOREIGN KEY (episode_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT fpk_METADATA_metadata_concept_id FOREIGN KEY (metadata_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT fpk_METADATA_metadata_type_concept_id FOREIGN KEY (metadata_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -313,5 +335,3 @@ ALTER TABLE @cdmDatabaseSchema.DRUG_STRENGTH ADD CONSTRAINT fpk_DRUG_STRENGTH_de
ALTER TABLE @cdmDatabaseSchema.COHORT_DEFINITION ADD CONSTRAINT fpk_COHORT_DEFINITION_definition_type_concept_id FOREIGN KEY (definition_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.COHORT_DEFINITION ADD CONSTRAINT fpk_COHORT_DEFINITION_subject_concept_id FOREIGN KEY (subject_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.ATTRIBUTE_DEFINITION ADD CONSTRAINT fpk_ATTRIBUTE_DEFINITION_attribute_type_concept_id FOREIGN KEY (attribute_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);

View File

@ -44,8 +44,8 @@ IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE (
visit_source_concept_id integer NULL,
admitted_from_concept_id integer NULL,
admitted_from_source_value varchar(50) NULL,
discharge_to_concept_id integer NULL,
discharge_to_source_value varchar(50) NULL,
discharged_to_concept_id integer NULL,
discharged_to_source_value varchar(50) NULL,
preceding_visit_occurrence_id integer NULL )
WITH (DISTRIBUTION = HASH(person_id));
@ -62,12 +62,12 @@ IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.VISIT_DETAIL (visi
care_site_id integer NULL,
visit_detail_source_value varchar(50) NULL,
visit_detail_source_concept_id Integer NULL,
admitted_from_source_value Varchar(50) NULL,
admitted_from_concept_id Integer NULL,
discharge_to_source_value Varchar(50) NULL,
discharge_to_concept_id integer NULL,
admitted_from_source_value Varchar(50) NULL,
discharged_to_source_value Varchar(50) NULL,
discharged_to_concept_id integer NULL,
preceding_visit_detail_id integer NULL,
visit_detail_parent_id integer NULL,
parent_visit_detail_id integer NULL,
visit_occurrence_id integer NOT NULL )
WITH (DISTRIBUTION = HASH(person_id));
@ -177,7 +177,10 @@ IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.MEASUREMENT (measu
measurement_source_value varchar(50) NULL,
measurement_source_concept_id integer NULL,
unit_source_value varchar(50) NULL,
value_source_value varchar(50) NULL )
unit_source_concept_id integer NULL,
value_source_value varchar(50) NULL,
measurement_event_id bigint NULL,
meas_event_field_concept_id integer NULL )
WITH (DISTRIBUTION = HASH(person_id));
--HINT DISTRIBUTE ON KEY (person_id)
@ -199,7 +202,9 @@ IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.OBSERVATION (obser
observation_source_concept_id integer NULL,
unit_source_value varchar(50) NULL,
qualifier_source_value varchar(50) NULL,
value_source_value varchar(50) NULL )
value_source_value varchar(50) NULL,
observation_event_id bigint NULL,
obs_event_field_concept_id integer NULL )
WITH (DISTRIBUTION = HASH(person_id));
--HINT DISTRIBUTE ON KEY (person_id)
@ -215,6 +220,8 @@ WITH (DISTRIBUTION = HASH(person_id));
--HINT DISTRIBUTE ON KEY (person_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.NOTE (note_id integer NOT NULL,
person_id integer NOT NULL,
note_event_id bigint NULL,
note_event_field_concept_id integer NULL,
note_date date NOT NULL,
note_datetime datetime NULL,
note_type_concept_id integer NOT NULL,
@ -386,12 +393,36 @@ IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.CONDITION_ERA (con
condition_occurrence_count integer NULL )
WITH (DISTRIBUTION = HASH(person_id));
--HINT DISTRIBUTE ON KEY (person_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.EPISODE (episode_id bigint NOT NULL,
person_id bigint NOT NULL,
episode_concept_id integer NOT NULL,
episode_start_date date NOT NULL,
episode_start_datetime datetime NULL,
episode_end_date date NULL,
episode_end_datetime datetime NULL,
episode_parent_id bigint NULL,
episode_number integer NULL,
episode_object_concept_id integer NOT NULL,
episode_type_concept_id integer NOT NULL,
episode_source_value varchar(50) NULL,
episode_source_concept_id integer NULL )
WITH (DISTRIBUTION = HASH(person_id));
--HINT DISTRIBUTE ON RANDOM
IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.METADATA (metadata_concept_id integer NOT NULL,
IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.EPISODE_EVENT (episode_id bigint NOT NULL,
event_id bigint NOT NULL,
episode_event_field_concept_id integer NOT NULL )
WITH (DISTRIBUTION = REPLICATE);
--HINT DISTRIBUTE ON RANDOM
IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.METADATA (metadata_id integer NOT NULL,
metadata_concept_id integer NOT NULL,
metadata_type_concept_id integer NOT NULL,
name varchar(250) NOT NULL,
value_as_string varchar(250) NULL,
value_as_concept_id integer NULL,
value_as_number float NULL,
metadata_date date NULL,
metadata_datetime datetime NULL )
WITH (DISTRIBUTION = REPLICATE);
@ -501,6 +532,13 @@ IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.DRUG_STRENGTH (dru
invalid_reason varchar(1) NULL )
WITH (DISTRIBUTION = REPLICATE);
--HINT DISTRIBUTE ON RANDOM
IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.COHORT (cohort_definition_id integer NOT NULL,
subject_id integer NOT NULL,
cohort_start_date date NOT NULL,
cohort_end_date date NOT NULL )
WITH (DISTRIBUTION = HASH(subject_id));
--HINT DISTRIBUTE ON RANDOM
IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.COHORT_DEFINITION (cohort_definition_id integer NOT NULL,
cohort_definition_name varchar(255) NOT NULL,
@ -510,11 +548,3 @@ IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.COHORT_DEFINITION
subject_concept_id integer NOT NULL,
cohort_initiation_date date NULL )
WITH (DISTRIBUTION = REPLICATE);
--HINT DISTRIBUTE ON RANDOM
IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.ATTRIBUTE_DEFINITION (attribute_definition_id integer NOT NULL,
attribute_name varchar(255) NOT NULL,
attribute_description VARCHAR(1000) NULL,
attribute_type_concept_id integer NOT NULL,
attribute_syntax VARCHAR(1000) NULL )
WITH (DISTRIBUTION = REPLICATE);

View File

@ -42,6 +42,10 @@ ALTER TABLE @cdmDatabaseSchema.DOSE_ERA ADD CONSTRAINT xpk_DOSE_ERA PRIMARY KEY
ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT xpk_CONDITION_ERA PRIMARY KEY NONCLUSTERED (condition_era_id);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT xpk_EPISODE PRIMARY KEY NONCLUSTERED (episode_id);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT xpk_METADATA PRIMARY KEY NONCLUSTERED (metadata_id);
ALTER TABLE @cdmDatabaseSchema.CONCEPT ADD CONSTRAINT xpk_CONCEPT PRIMARY KEY NONCLUSTERED (concept_id);
ALTER TABLE @cdmDatabaseSchema.VOCABULARY ADD CONSTRAINT xpk_VOCABULARY PRIMARY KEY NONCLUSTERED (vocabulary_id);

View File

@ -36,7 +36,7 @@ ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRE
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_admitted_from_concept_id FOREIGN KEY (admitted_from_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_discharge_to_concept_id FOREIGN KEY (discharge_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_discharged_to_concept_id FOREIGN KEY (discharged_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_preceding_visit_occurrence_id FOREIGN KEY (preceding_visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID);
@ -54,11 +54,11 @@ ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visi
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_admitted_from_concept_id FOREIGN KEY (admitted_from_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_discharge_to_concept_id FOREIGN KEY (discharge_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_discharged_to_concept_id FOREIGN KEY (discharged_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_preceding_visit_detail_id FOREIGN KEY (preceding_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visit_detail_parent_id FOREIGN KEY (visit_detail_parent_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_parent_visit_detail_id FOREIGN KEY (parent_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID);
@ -136,6 +136,10 @@ ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_visit_
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_measurement_source_concept_id FOREIGN KEY (measurement_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_unit_source_concept_id FOREIGN KEY (unit_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_meas_event_field_concept_id FOREIGN KEY (meas_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_observation_concept_id FOREIGN KEY (observation_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -156,6 +160,8 @@ ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_visit_
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_observation_source_concept_id FOREIGN KEY (observation_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_obs_event_field_concept_id FOREIGN KEY (obs_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_death_type_concept_id FOREIGN KEY (death_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -166,6 +172,8 @@ ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_cause_source_conce
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_event_field_concept_id FOREIGN KEY (note_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_type_concept_id FOREIGN KEY (note_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_class_concept_id FOREIGN KEY (note_class_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -260,6 +268,20 @@ ALTER TABLE @cdmDatabaseSchema.DOSE_ERA ADD CONSTRAINT fpk_DOSE_ERA_unit_concept
ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT fpk_CONDITION_ERA_condition_concept_id FOREIGN KEY (condition_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_concept_id FOREIGN KEY (episode_concept_id) REFERENCES @cdmDatabaseSchema. ();
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_object_concept_id FOREIGN KEY (episode_object_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_type_concept_id FOREIGN KEY (episode_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_source_concept_id FOREIGN KEY (episode_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE_EVENT ADD CONSTRAINT fpk_EPISODE_EVENT_episode_id FOREIGN KEY (episode_id) REFERENCES @cdmDatabaseSchema.EPISODE (EPISODE_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE_EVENT ADD CONSTRAINT fpk_EPISODE_EVENT_episode_event_field_concept_id FOREIGN KEY (episode_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT fpk_METADATA_metadata_concept_id FOREIGN KEY (metadata_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT fpk_METADATA_metadata_type_concept_id FOREIGN KEY (metadata_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -313,5 +335,3 @@ ALTER TABLE @cdmDatabaseSchema.DRUG_STRENGTH ADD CONSTRAINT fpk_DRUG_STRENGTH_de
ALTER TABLE @cdmDatabaseSchema.COHORT_DEFINITION ADD CONSTRAINT fpk_COHORT_DEFINITION_definition_type_concept_id FOREIGN KEY (definition_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.COHORT_DEFINITION ADD CONSTRAINT fpk_COHORT_DEFINITION_subject_concept_id FOREIGN KEY (subject_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.ATTRIBUTE_DEFINITION ADD CONSTRAINT fpk_ATTRIBUTE_DEFINITION_attribute_type_concept_id FOREIGN KEY (attribute_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);

View File

@ -45,8 +45,8 @@ CREATE TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE (
visit_source_concept_id integer NULL,
admitted_from_concept_id integer NULL,
admitted_from_source_value varchar(50) NULL,
discharge_to_concept_id integer NULL,
discharge_to_source_value varchar(50) NULL,
discharged_to_concept_id integer NULL,
discharged_to_source_value varchar(50) NULL,
preceding_visit_occurrence_id integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
@ -63,12 +63,12 @@ CREATE TABLE @cdmDatabaseSchema.VISIT_DETAIL (
care_site_id integer NULL,
visit_detail_source_value varchar(50) NULL,
visit_detail_source_concept_id Integer NULL,
admitted_from_source_value Varchar(50) NULL,
admitted_from_concept_id Integer NULL,
discharge_to_source_value Varchar(50) NULL,
discharge_to_concept_id integer NULL,
admitted_from_source_value Varchar(50) NULL,
discharged_to_source_value Varchar(50) NULL,
discharged_to_concept_id integer NULL,
preceding_visit_detail_id integer NULL,
visit_detail_parent_id integer NULL,
parent_visit_detail_id integer NULL,
visit_occurrence_id integer NOT NULL );
--HINT DISTRIBUTE ON KEY (person_id)
@ -178,7 +178,10 @@ CREATE TABLE @cdmDatabaseSchema.MEASUREMENT (
measurement_source_value varchar(50) NULL,
measurement_source_concept_id integer NULL,
unit_source_value varchar(50) NULL,
value_source_value varchar(50) NULL );
unit_source_concept_id integer NULL,
value_source_value varchar(50) NULL,
measurement_event_id bigint NULL,
meas_event_field_concept_id integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
CREATE TABLE @cdmDatabaseSchema.OBSERVATION (
@ -200,7 +203,9 @@ CREATE TABLE @cdmDatabaseSchema.OBSERVATION (
observation_source_concept_id integer NULL,
unit_source_value varchar(50) NULL,
qualifier_source_value varchar(50) NULL,
value_source_value varchar(50) NULL );
value_source_value varchar(50) NULL,
observation_event_id bigint NULL,
obs_event_field_concept_id integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
CREATE TABLE @cdmDatabaseSchema.DEATH (
@ -216,6 +221,8 @@ CREATE TABLE @cdmDatabaseSchema.DEATH (
CREATE TABLE @cdmDatabaseSchema.NOTE (
note_id integer NOT NULL,
person_id integer NOT NULL,
note_event_id bigint NULL,
note_event_field_concept_id integer NULL,
note_date date NOT NULL,
note_datetime TIMESTAMP NULL,
note_type_concept_id integer NOT NULL,
@ -386,13 +393,37 @@ CREATE TABLE @cdmDatabaseSchema.CONDITION_ERA (
condition_era_end_date TIMESTAMP NOT NULL,
condition_occurrence_count integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
CREATE TABLE @cdmDatabaseSchema.EPISODE (
episode_id bigint NOT NULL,
person_id bigint NOT NULL,
episode_concept_id integer NOT NULL,
episode_start_date date NOT NULL,
episode_start_datetime TIMESTAMP NULL,
episode_end_date date NULL,
episode_end_datetime TIMESTAMP NULL,
episode_parent_id bigint NULL,
episode_number integer NULL,
episode_object_concept_id integer NOT NULL,
episode_type_concept_id integer NOT NULL,
episode_source_value varchar(50) NULL,
episode_source_concept_id integer NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.EPISODE_EVENT (
episode_id bigint NOT NULL,
event_id bigint NOT NULL,
episode_event_field_concept_id integer NOT NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.METADATA (
metadata_id integer NOT NULL,
metadata_concept_id integer NOT NULL,
metadata_type_concept_id integer NOT NULL,
name varchar(250) NOT NULL,
value_as_string varchar(250) NULL,
value_as_concept_id integer NULL,
value_as_number NUMERIC NULL,
metadata_date date NULL,
metadata_datetime TIMESTAMP NULL );
@ -501,6 +532,13 @@ CREATE TABLE @cdmDatabaseSchema.DRUG_STRENGTH (
valid_end_date date NOT NULL,
invalid_reason varchar(1) NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.COHORT (
cohort_definition_id integer NOT NULL,
subject_id integer NOT NULL,
cohort_start_date date NOT NULL,
cohort_end_date date NOT NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.COHORT_DEFINITION (
cohort_definition_id integer NOT NULL,
@ -510,11 +548,3 @@ CREATE TABLE @cdmDatabaseSchema.COHORT_DEFINITION (
cohort_definition_syntax TEXT NULL,
subject_concept_id integer NOT NULL,
cohort_initiation_date date NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.ATTRIBUTE_DEFINITION (
attribute_definition_id integer NOT NULL,
attribute_name varchar(255) NOT NULL,
attribute_description TEXT NULL,
attribute_type_concept_id integer NOT NULL,
attribute_syntax TEXT NULL );

View File

@ -42,6 +42,10 @@ ALTER TABLE @cdmDatabaseSchema.DOSE_ERA ADD CONSTRAINT xpk_DOSE_ERA PRIMARY KEY
ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT xpk_CONDITION_ERA PRIMARY KEY (condition_era_id);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT xpk_EPISODE PRIMARY KEY (episode_id);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT xpk_METADATA PRIMARY KEY (metadata_id);
ALTER TABLE @cdmDatabaseSchema.CONCEPT ADD CONSTRAINT xpk_CONCEPT PRIMARY KEY (concept_id);
ALTER TABLE @cdmDatabaseSchema.VOCABULARY ADD CONSTRAINT xpk_VOCABULARY PRIMARY KEY (vocabulary_id);

View File

@ -36,7 +36,7 @@ ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRE
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_admitted_from_concept_id FOREIGN KEY (admitted_from_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_discharge_to_concept_id FOREIGN KEY (discharge_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_discharged_to_concept_id FOREIGN KEY (discharged_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_preceding_visit_occurrence_id FOREIGN KEY (preceding_visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID);
@ -54,11 +54,11 @@ ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visi
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_admitted_from_concept_id FOREIGN KEY (admitted_from_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_discharge_to_concept_id FOREIGN KEY (discharge_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_discharged_to_concept_id FOREIGN KEY (discharged_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_preceding_visit_detail_id FOREIGN KEY (preceding_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visit_detail_parent_id FOREIGN KEY (visit_detail_parent_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_parent_visit_detail_id FOREIGN KEY (parent_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID);
@ -136,6 +136,10 @@ ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_visit_
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_measurement_source_concept_id FOREIGN KEY (measurement_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_unit_source_concept_id FOREIGN KEY (unit_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_meas_event_field_concept_id FOREIGN KEY (meas_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_observation_concept_id FOREIGN KEY (observation_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -156,6 +160,8 @@ ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_visit_
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_observation_source_concept_id FOREIGN KEY (observation_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_obs_event_field_concept_id FOREIGN KEY (obs_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_death_type_concept_id FOREIGN KEY (death_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -166,6 +172,8 @@ ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_cause_source_conce
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_event_field_concept_id FOREIGN KEY (note_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_type_concept_id FOREIGN KEY (note_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_class_concept_id FOREIGN KEY (note_class_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -260,6 +268,20 @@ ALTER TABLE @cdmDatabaseSchema.DOSE_ERA ADD CONSTRAINT fpk_DOSE_ERA_unit_concept
ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT fpk_CONDITION_ERA_condition_concept_id FOREIGN KEY (condition_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_concept_id FOREIGN KEY (episode_concept_id) REFERENCES @cdmDatabaseSchema. ();
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_object_concept_id FOREIGN KEY (episode_object_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_type_concept_id FOREIGN KEY (episode_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_source_concept_id FOREIGN KEY (episode_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE_EVENT ADD CONSTRAINT fpk_EPISODE_EVENT_episode_id FOREIGN KEY (episode_id) REFERENCES @cdmDatabaseSchema.EPISODE (EPISODE_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE_EVENT ADD CONSTRAINT fpk_EPISODE_EVENT_episode_event_field_concept_id FOREIGN KEY (episode_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT fpk_METADATA_metadata_concept_id FOREIGN KEY (metadata_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT fpk_METADATA_metadata_type_concept_id FOREIGN KEY (metadata_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -313,5 +335,3 @@ ALTER TABLE @cdmDatabaseSchema.DRUG_STRENGTH ADD CONSTRAINT fpk_DRUG_STRENGTH_de
ALTER TABLE @cdmDatabaseSchema.COHORT_DEFINITION ADD CONSTRAINT fpk_COHORT_DEFINITION_definition_type_concept_id FOREIGN KEY (definition_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.COHORT_DEFINITION ADD CONSTRAINT fpk_COHORT_DEFINITION_subject_concept_id FOREIGN KEY (subject_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.ATTRIBUTE_DEFINITION ADD CONSTRAINT fpk_ATTRIBUTE_DEFINITION_attribute_type_concept_id FOREIGN KEY (attribute_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);

View File

@ -44,8 +44,8 @@ CREATE TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE (visit_occurrence_id integer N
visit_source_concept_id integer NULL,
admitted_from_concept_id integer NULL,
admitted_from_source_value varchar(50) NULL,
discharge_to_concept_id integer NULL,
discharge_to_source_value varchar(50) NULL,
discharged_to_concept_id integer NULL,
discharged_to_source_value varchar(50) NULL,
preceding_visit_occurrence_id integer NULL )
DISTKEY(person_id);
@ -62,12 +62,12 @@ CREATE TABLE @cdmDatabaseSchema.VISIT_DETAIL (visit_detail_id integer NOT NULL,
care_site_id integer NULL,
visit_detail_source_value varchar(50) NULL,
visit_detail_source_concept_id Integer NULL,
admitted_from_source_value Varchar(50) NULL,
admitted_from_concept_id Integer NULL,
discharge_to_source_value Varchar(50) NULL,
discharge_to_concept_id integer NULL,
admitted_from_source_value Varchar(50) NULL,
discharged_to_source_value Varchar(50) NULL,
discharged_to_concept_id integer NULL,
preceding_visit_detail_id integer NULL,
visit_detail_parent_id integer NULL,
parent_visit_detail_id integer NULL,
visit_occurrence_id integer NOT NULL )
DISTKEY(person_id);
@ -177,7 +177,10 @@ CREATE TABLE @cdmDatabaseSchema.MEASUREMENT (measurement_id integer NOT NULL,
measurement_source_value varchar(50) NULL,
measurement_source_concept_id integer NULL,
unit_source_value varchar(50) NULL,
value_source_value varchar(50) NULL )
unit_source_concept_id integer NULL,
value_source_value varchar(50) NULL,
measurement_event_id bigint NULL,
meas_event_field_concept_id integer NULL )
DISTKEY(person_id);
--HINT DISTRIBUTE ON KEY (person_id)
@ -199,7 +202,9 @@ CREATE TABLE @cdmDatabaseSchema.OBSERVATION (observation_id integer NOT NULL,
observation_source_concept_id integer NULL,
unit_source_value varchar(50) NULL,
qualifier_source_value varchar(50) NULL,
value_source_value varchar(50) NULL )
value_source_value varchar(50) NULL,
observation_event_id bigint NULL,
obs_event_field_concept_id integer NULL )
DISTKEY(person_id);
--HINT DISTRIBUTE ON KEY (person_id)
@ -215,6 +220,8 @@ DISTKEY(person_id);
--HINT DISTRIBUTE ON KEY (person_id)
CREATE TABLE @cdmDatabaseSchema.NOTE (note_id integer NOT NULL,
person_id integer NOT NULL,
note_event_id bigint NULL,
note_event_field_concept_id integer NULL,
note_date date NOT NULL,
note_datetime TIMESTAMP NULL,
note_type_concept_id integer NOT NULL,
@ -386,12 +393,36 @@ CREATE TABLE @cdmDatabaseSchema.CONDITION_ERA (condition_era_id integer NOT NUL
condition_occurrence_count integer NULL )
DISTKEY(person_id);
--HINT DISTRIBUTE ON KEY (person_id)
CREATE TABLE @cdmDatabaseSchema.EPISODE (episode_id bigint NOT NULL,
person_id bigint NOT NULL,
episode_concept_id integer NOT NULL,
episode_start_date date NOT NULL,
episode_start_datetime TIMESTAMP NULL,
episode_end_date date NULL,
episode_end_datetime TIMESTAMP NULL,
episode_parent_id bigint NULL,
episode_number integer NULL,
episode_object_concept_id integer NOT NULL,
episode_type_concept_id integer NOT NULL,
episode_source_value varchar(50) NULL,
episode_source_concept_id integer NULL )
DISTKEY(person_id);
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.METADATA (metadata_concept_id integer NOT NULL,
CREATE TABLE @cdmDatabaseSchema.EPISODE_EVENT (episode_id bigint NOT NULL,
event_id bigint NOT NULL,
episode_event_field_concept_id integer NOT NULL )
DISTSTYLE ALL;
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.METADATA (metadata_id integer NOT NULL,
metadata_concept_id integer NOT NULL,
metadata_type_concept_id integer NOT NULL,
name varchar(250) NOT NULL,
value_as_string varchar(250) NULL,
value_as_concept_id integer NULL,
value_as_number float NULL,
metadata_date date NULL,
metadata_datetime TIMESTAMP NULL )
DISTSTYLE ALL;
@ -501,6 +532,13 @@ CREATE TABLE @cdmDatabaseSchema.DRUG_STRENGTH (drug_concept_id integer NOT NULL
invalid_reason varchar(1) NULL )
DISTSTYLE ALL;
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.COHORT (cohort_definition_id integer NOT NULL,
subject_id integer NOT NULL,
cohort_start_date date NOT NULL,
cohort_end_date date NOT NULL )
DISTKEY(subject_id);
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.COHORT_DEFINITION (cohort_definition_id integer NOT NULL,
cohort_definition_name varchar(255) NOT NULL,
@ -510,11 +548,3 @@ CREATE TABLE @cdmDatabaseSchema.COHORT_DEFINITION (cohort_definition_id integer
subject_concept_id integer NOT NULL,
cohort_initiation_date date NULL )
DISTSTYLE ALL;
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.ATTRIBUTE_DEFINITION (attribute_definition_id integer NOT NULL,
attribute_name varchar(255) NOT NULL,
attribute_description varchar(MAX) NULL,
attribute_type_concept_id integer NOT NULL,
attribute_syntax varchar(MAX) NULL )
DISTSTYLE ALL;

View File

@ -42,6 +42,10 @@ ALTER TABLE @cdmDatabaseSchema.DOSE_ERA ADD CONSTRAINT xpk_DOSE_ERA PRIMARY KEY
ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT xpk_CONDITION_ERA PRIMARY KEY (condition_era_id);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT xpk_EPISODE PRIMARY KEY (episode_id);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT xpk_METADATA PRIMARY KEY (metadata_id);
ALTER TABLE @cdmDatabaseSchema.CONCEPT ADD CONSTRAINT xpk_CONCEPT PRIMARY KEY (concept_id);
ALTER TABLE @cdmDatabaseSchema.VOCABULARY ADD CONSTRAINT xpk_VOCABULARY PRIMARY KEY (vocabulary_id);

View File

@ -36,7 +36,7 @@ ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRE
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_admitted_from_concept_id FOREIGN KEY (admitted_from_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_discharge_to_concept_id FOREIGN KEY (discharge_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_discharged_to_concept_id FOREIGN KEY (discharged_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT fpk_VISIT_OCCURRENCE_preceding_visit_occurrence_id FOREIGN KEY (preceding_visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID);
@ -54,11 +54,11 @@ ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visi
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_admitted_from_concept_id FOREIGN KEY (admitted_from_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_discharge_to_concept_id FOREIGN KEY (discharge_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_discharged_to_concept_id FOREIGN KEY (discharged_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_preceding_visit_detail_id FOREIGN KEY (preceding_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visit_detail_parent_id FOREIGN KEY (visit_detail_parent_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_parent_visit_detail_id FOREIGN KEY (parent_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID);
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT fpk_VISIT_DETAIL_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID);
@ -136,6 +136,10 @@ ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_visit_
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_measurement_source_concept_id FOREIGN KEY (measurement_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_unit_source_concept_id FOREIGN KEY (unit_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT fpk_MEASUREMENT_meas_event_field_concept_id FOREIGN KEY (meas_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_observation_concept_id FOREIGN KEY (observation_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -156,6 +160,8 @@ ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_visit_
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_observation_source_concept_id FOREIGN KEY (observation_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT fpk_OBSERVATION_obs_event_field_concept_id FOREIGN KEY (obs_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_death_type_concept_id FOREIGN KEY (death_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -166,6 +172,8 @@ ALTER TABLE @cdmDatabaseSchema.DEATH ADD CONSTRAINT fpk_DEATH_cause_source_conce
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_event_field_concept_id FOREIGN KEY (note_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_type_concept_id FOREIGN KEY (note_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT fpk_NOTE_note_class_concept_id FOREIGN KEY (note_class_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -260,6 +268,20 @@ ALTER TABLE @cdmDatabaseSchema.DOSE_ERA ADD CONSTRAINT fpk_DOSE_ERA_unit_concept
ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT fpk_CONDITION_ERA_condition_concept_id FOREIGN KEY (condition_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_concept_id FOREIGN KEY (episode_concept_id) REFERENCES @cdmDatabaseSchema. ();
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_object_concept_id FOREIGN KEY (episode_object_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_type_concept_id FOREIGN KEY (episode_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_source_concept_id FOREIGN KEY (episode_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE_EVENT ADD CONSTRAINT fpk_EPISODE_EVENT_episode_id FOREIGN KEY (episode_id) REFERENCES @cdmDatabaseSchema.EPISODE (EPISODE_ID);
ALTER TABLE @cdmDatabaseSchema.EPISODE_EVENT ADD CONSTRAINT fpk_EPISODE_EVENT_episode_event_field_concept_id FOREIGN KEY (episode_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT fpk_METADATA_metadata_concept_id FOREIGN KEY (metadata_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT fpk_METADATA_metadata_type_concept_id FOREIGN KEY (metadata_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
@ -313,5 +335,3 @@ ALTER TABLE @cdmDatabaseSchema.DRUG_STRENGTH ADD CONSTRAINT fpk_DRUG_STRENGTH_de
ALTER TABLE @cdmDatabaseSchema.COHORT_DEFINITION ADD CONSTRAINT fpk_COHORT_DEFINITION_definition_type_concept_id FOREIGN KEY (definition_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.COHORT_DEFINITION ADD CONSTRAINT fpk_COHORT_DEFINITION_subject_concept_id FOREIGN KEY (subject_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
ALTER TABLE @cdmDatabaseSchema.ATTRIBUTE_DEFINITION ADD CONSTRAINT fpk_ATTRIBUTE_DEFINITION_attribute_type_concept_id FOREIGN KEY (attribute_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);

View File

@ -45,8 +45,8 @@ CREATE TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE (
visit_source_concept_id integer NULL,
admitted_from_concept_id integer NULL,
admitted_from_source_value varchar(50) NULL,
discharge_to_concept_id integer NULL,
discharge_to_source_value varchar(50) NULL,
discharged_to_concept_id integer NULL,
discharged_to_source_value varchar(50) NULL,
preceding_visit_occurrence_id integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
@ -63,12 +63,12 @@ CREATE TABLE @cdmDatabaseSchema.VISIT_DETAIL (
care_site_id integer NULL,
visit_detail_source_value varchar(50) NULL,
visit_detail_source_concept_id Integer NULL,
admitted_from_source_value Varchar(50) NULL,
admitted_from_concept_id Integer NULL,
discharge_to_source_value Varchar(50) NULL,
discharge_to_concept_id integer NULL,
admitted_from_source_value Varchar(50) NULL,
discharged_to_source_value Varchar(50) NULL,
discharged_to_concept_id integer NULL,
preceding_visit_detail_id integer NULL,
visit_detail_parent_id integer NULL,
parent_visit_detail_id integer NULL,
visit_occurrence_id integer NOT NULL );
--HINT DISTRIBUTE ON KEY (person_id)
@ -178,7 +178,10 @@ CREATE TABLE @cdmDatabaseSchema.MEASUREMENT (
measurement_source_value varchar(50) NULL,
measurement_source_concept_id integer NULL,
unit_source_value varchar(50) NULL,
value_source_value varchar(50) NULL );
unit_source_concept_id integer NULL,
value_source_value varchar(50) NULL,
measurement_event_id bigint NULL,
meas_event_field_concept_id integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
CREATE TABLE @cdmDatabaseSchema.OBSERVATION (
@ -200,7 +203,9 @@ CREATE TABLE @cdmDatabaseSchema.OBSERVATION (
observation_source_concept_id integer NULL,
unit_source_value varchar(50) NULL,
qualifier_source_value varchar(50) NULL,
value_source_value varchar(50) NULL );
value_source_value varchar(50) NULL,
observation_event_id bigint NULL,
obs_event_field_concept_id integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
CREATE TABLE @cdmDatabaseSchema.DEATH (
@ -216,6 +221,8 @@ CREATE TABLE @cdmDatabaseSchema.DEATH (
CREATE TABLE @cdmDatabaseSchema.NOTE (
note_id integer NOT NULL,
person_id integer NOT NULL,
note_event_id bigint NULL,
note_event_field_concept_id integer NULL,
note_date date NOT NULL,
note_datetime datetime NULL,
note_type_concept_id integer NOT NULL,
@ -386,13 +393,37 @@ CREATE TABLE @cdmDatabaseSchema.CONDITION_ERA (
condition_era_end_date datetime NOT NULL,
condition_occurrence_count integer NULL );
--HINT DISTRIBUTE ON KEY (person_id)
CREATE TABLE @cdmDatabaseSchema.EPISODE (
episode_id bigint NOT NULL,
person_id bigint NOT NULL,
episode_concept_id integer NOT NULL,
episode_start_date date NOT NULL,
episode_start_datetime datetime NULL,
episode_end_date date NULL,
episode_end_datetime datetime NULL,
episode_parent_id bigint NULL,
episode_number integer NULL,
episode_object_concept_id integer NOT NULL,
episode_type_concept_id integer NOT NULL,
episode_source_value varchar(50) NULL,
episode_source_concept_id integer NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.EPISODE_EVENT (
episode_id bigint NOT NULL,
event_id bigint NOT NULL,
episode_event_field_concept_id integer NOT NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.METADATA (
metadata_id integer NOT NULL,
metadata_concept_id integer NOT NULL,
metadata_type_concept_id integer NOT NULL,
name varchar(250) NOT NULL,
value_as_string varchar(250) NULL,
value_as_concept_id integer NULL,
value_as_number float NULL,
metadata_date date NULL,
metadata_datetime datetime NULL );
@ -501,6 +532,13 @@ CREATE TABLE @cdmDatabaseSchema.DRUG_STRENGTH (
valid_end_date date NOT NULL,
invalid_reason varchar(1) NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.COHORT (
cohort_definition_id integer NOT NULL,
subject_id integer NOT NULL,
cohort_start_date date NOT NULL,
cohort_end_date date NOT NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.COHORT_DEFINITION (
cohort_definition_id integer NOT NULL,
@ -510,11 +548,3 @@ CREATE TABLE @cdmDatabaseSchema.COHORT_DEFINITION (
cohort_definition_syntax varchar(MAX) NULL,
subject_concept_id integer NOT NULL,
cohort_initiation_date date NULL );
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE @cdmDatabaseSchema.ATTRIBUTE_DEFINITION (
attribute_definition_id integer NOT NULL,
attribute_name varchar(255) NOT NULL,
attribute_description varchar(MAX) NULL,
attribute_type_concept_id integer NOT NULL,
attribute_syntax varchar(MAX) NULL );

View File

@ -42,6 +42,10 @@ ALTER TABLE @cdmDatabaseSchema.DOSE_ERA ADD CONSTRAINT xpk_DOSE_ERA PRIMARY KEY
ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT xpk_CONDITION_ERA PRIMARY KEY NONCLUSTERED (condition_era_id);
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT xpk_EPISODE PRIMARY KEY NONCLUSTERED (episode_id);
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT xpk_METADATA PRIMARY KEY NONCLUSTERED (metadata_id);
ALTER TABLE @cdmDatabaseSchema.CONCEPT ADD CONSTRAINT xpk_CONCEPT PRIMARY KEY NONCLUSTERED (concept_id);
ALTER TABLE @cdmDatabaseSchema.VOCABULARY ADD CONSTRAINT xpk_VOCABULARY PRIMARY KEY NONCLUSTERED (vocabulary_id);