Foreign key fixes
This commit is contained in:
parent
690c9edf40
commit
041291eb27
|
@ -2,3 +2,4 @@
|
|||
.Rhistory
|
||||
.RData
|
||||
.Ruserdata
|
||||
extras/CodeToRun.R
|
||||
|
|
|
@ -270,7 +270,7 @@ alter table @cdmDatabaseSchema.condition_era add constraint fpk_condition_era_co
|
|||
|
||||
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_concept_id foreign key (episode_concept_id) references @cdmDatabaseSchema.concept (concept_id);
|
||||
|
||||
alter table @cdmDatabaseSchema.episode add constraint fpk_episode_episode_object_concept_id foreign key (episode_object_concept_id) references @cdmDatabaseSchema.concept (concept_id);
|
||||
|
||||
|
|
|
@ -270,7 +270,7 @@ ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT fpk_CONDITION_ERA_co
|
|||
|
||||
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_concept_id FOREIGN KEY (episode_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
|
||||
|
||||
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_object_concept_id FOREIGN KEY (episode_object_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
|
||||
|
||||
|
|
|
@ -395,14 +395,14 @@ CREATE TABLE @cdmDatabaseSchema.CONDITION_ERA (
|
|||
|
||||
--HINT DISTRIBUTE ON KEY (person_id)
|
||||
CREATE TABLE @cdmDatabaseSchema.EPISODE (
|
||||
episode_id BIGINT,
|
||||
person_id BIGINT,
|
||||
episode_id INT,
|
||||
person_id INT,
|
||||
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_parent_id integer NULL,
|
||||
episode_number integer NULL,
|
||||
episode_object_concept_id INT,
|
||||
episode_type_concept_id INT,
|
||||
|
@ -411,8 +411,8 @@ CREATE TABLE @cdmDatabaseSchema.EPISODE (
|
|||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
CREATE TABLE @cdmDatabaseSchema.EPISODE_EVENT (
|
||||
episode_id BIGINT,
|
||||
event_id BIGINT,
|
||||
episode_id INT,
|
||||
event_id INT,
|
||||
episode_event_field_concept_id INT );
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
|
|
|
@ -270,7 +270,7 @@ ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT fpk_CONDITION_ERA_co
|
|||
|
||||
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_concept_id FOREIGN KEY (episode_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
|
||||
|
||||
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_object_concept_id FOREIGN KEY (episode_object_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
|
||||
|
||||
|
|
|
@ -395,14 +395,14 @@ CREATE TABLE @cdmDatabaseSchema.CONDITION_ERA (
|
|||
|
||||
--HINT DISTRIBUTE ON KEY (person_id)
|
||||
CREATE TABLE @cdmDatabaseSchema.EPISODE (
|
||||
episode_id bigint NOT NULL,
|
||||
person_id bigint NOT NULL,
|
||||
episode_id integer NOT NULL,
|
||||
person_id integer 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_parent_id integer NULL,
|
||||
episode_number integer NULL,
|
||||
episode_object_concept_id integer NOT NULL,
|
||||
episode_type_concept_id integer NOT NULL,
|
||||
|
@ -411,8 +411,8 @@ CREATE TABLE @cdmDatabaseSchema.EPISODE (
|
|||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
CREATE TABLE @cdmDatabaseSchema.EPISODE_EVENT (
|
||||
episode_id bigint NOT NULL,
|
||||
event_id bigint NOT NULL,
|
||||
episode_id integer NOT NULL,
|
||||
event_id integer NOT NULL,
|
||||
episode_event_field_concept_id integer NOT NULL );
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
|
|
|
@ -270,7 +270,7 @@ ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT fpk_CONDITION_ERA_co
|
|||
|
||||
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_concept_id FOREIGN KEY (episode_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
|
||||
|
||||
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_object_concept_id FOREIGN KEY (episode_object_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
|
||||
|
||||
|
|
|
@ -395,14 +395,14 @@ CREATE TABLE @cdmDatabaseSchema.CONDITION_ERA (
|
|||
|
||||
--HINT DISTRIBUTE ON KEY (person_id)
|
||||
CREATE TABLE @cdmDatabaseSchema.EPISODE (
|
||||
episode_id NUMBER(19) NOT NULL,
|
||||
person_id NUMBER(19) NOT NULL,
|
||||
episode_id integer NOT NULL,
|
||||
person_id integer 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_parent_id integer NULL,
|
||||
episode_number integer NULL,
|
||||
episode_object_concept_id integer NOT NULL,
|
||||
episode_type_concept_id integer NOT NULL,
|
||||
|
@ -411,8 +411,8 @@ CREATE TABLE @cdmDatabaseSchema.EPISODE (
|
|||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
CREATE TABLE @cdmDatabaseSchema.EPISODE_EVENT (
|
||||
episode_id NUMBER(19) NOT NULL,
|
||||
event_id NUMBER(19) NOT NULL,
|
||||
episode_id integer NOT NULL,
|
||||
event_id integer NOT NULL,
|
||||
episode_event_field_concept_id integer NOT NULL );
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
|
|
|
@ -270,7 +270,7 @@ ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT fpk_CONDITION_ERA_co
|
|||
|
||||
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_concept_id FOREIGN KEY (episode_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
|
||||
|
||||
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_object_concept_id FOREIGN KEY (episode_object_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
|
||||
|
||||
|
|
|
@ -394,14 +394,14 @@ IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.CONDITION_ERA (con
|
|||
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,
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.EPISODE (episode_id integer NOT NULL,
|
||||
person_id integer 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_parent_id integer NULL,
|
||||
episode_number integer NULL,
|
||||
episode_object_concept_id integer NOT NULL,
|
||||
episode_type_concept_id integer NOT NULL,
|
||||
|
@ -410,8 +410,8 @@ IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.EPISODE (episode_i
|
|||
WITH (DISTRIBUTION = HASH(person_id));
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.EPISODE_EVENT (episode_id bigint NOT NULL,
|
||||
event_id bigint NOT NULL,
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE @cdmDatabaseSchema.EPISODE_EVENT (episode_id integer NOT NULL,
|
||||
event_id integer NOT NULL,
|
||||
episode_event_field_concept_id integer NOT NULL )
|
||||
WITH (DISTRIBUTION = REPLICATE);
|
||||
|
||||
|
|
|
@ -270,7 +270,7 @@ ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT fpk_CONDITION_ERA_co
|
|||
|
||||
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_concept_id FOREIGN KEY (episode_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
|
||||
|
||||
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_object_concept_id FOREIGN KEY (episode_object_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
|
||||
|
||||
|
|
|
@ -395,14 +395,14 @@ CREATE TABLE @cdmDatabaseSchema.CONDITION_ERA (
|
|||
|
||||
--HINT DISTRIBUTE ON KEY (person_id)
|
||||
CREATE TABLE @cdmDatabaseSchema.EPISODE (
|
||||
episode_id bigint NOT NULL,
|
||||
person_id bigint NOT NULL,
|
||||
episode_id integer NOT NULL,
|
||||
person_id integer 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_parent_id integer NULL,
|
||||
episode_number integer NULL,
|
||||
episode_object_concept_id integer NOT NULL,
|
||||
episode_type_concept_id integer NOT NULL,
|
||||
|
@ -411,8 +411,8 @@ CREATE TABLE @cdmDatabaseSchema.EPISODE (
|
|||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
CREATE TABLE @cdmDatabaseSchema.EPISODE_EVENT (
|
||||
episode_id bigint NOT NULL,
|
||||
event_id bigint NOT NULL,
|
||||
episode_id integer NOT NULL,
|
||||
event_id integer NOT NULL,
|
||||
episode_event_field_concept_id integer NOT NULL );
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
|
|
|
@ -270,7 +270,7 @@ ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT fpk_CONDITION_ERA_co
|
|||
|
||||
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_concept_id FOREIGN KEY (episode_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
|
||||
|
||||
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_object_concept_id FOREIGN KEY (episode_object_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
|
||||
|
||||
|
|
|
@ -394,14 +394,14 @@ CREATE TABLE @cdmDatabaseSchema.CONDITION_ERA (condition_era_id integer NOT NUL
|
|||
DISTKEY(person_id);
|
||||
|
||||
--HINT DISTRIBUTE ON KEY (person_id)
|
||||
CREATE TABLE @cdmDatabaseSchema.EPISODE (episode_id bigint NOT NULL,
|
||||
person_id bigint NOT NULL,
|
||||
CREATE TABLE @cdmDatabaseSchema.EPISODE (episode_id integer NOT NULL,
|
||||
person_id integer 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_parent_id integer NULL,
|
||||
episode_number integer NULL,
|
||||
episode_object_concept_id integer NOT NULL,
|
||||
episode_type_concept_id integer NOT NULL,
|
||||
|
@ -410,8 +410,8 @@ CREATE TABLE @cdmDatabaseSchema.EPISODE (episode_id bigint NOT NULL,
|
|||
DISTKEY(person_id);
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
CREATE TABLE @cdmDatabaseSchema.EPISODE_EVENT (episode_id bigint NOT NULL,
|
||||
event_id bigint NOT NULL,
|
||||
CREATE TABLE @cdmDatabaseSchema.EPISODE_EVENT (episode_id integer NOT NULL,
|
||||
event_id integer NOT NULL,
|
||||
episode_event_field_concept_id integer NOT NULL )
|
||||
DISTSTYLE ALL;
|
||||
|
||||
|
|
|
@ -270,7 +270,7 @@ ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT fpk_CONDITION_ERA_co
|
|||
|
||||
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_concept_id FOREIGN KEY (episode_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
|
||||
|
||||
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT fpk_EPISODE_episode_object_concept_id FOREIGN KEY (episode_object_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID);
|
||||
|
||||
|
|
|
@ -395,14 +395,14 @@ CREATE TABLE @cdmDatabaseSchema.CONDITION_ERA (
|
|||
|
||||
--HINT DISTRIBUTE ON KEY (person_id)
|
||||
CREATE TABLE @cdmDatabaseSchema.EPISODE (
|
||||
episode_id bigint NOT NULL,
|
||||
person_id bigint NOT NULL,
|
||||
episode_id integer NOT NULL,
|
||||
person_id integer 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_parent_id integer NULL,
|
||||
episode_number integer NULL,
|
||||
episode_object_concept_id integer NOT NULL,
|
||||
episode_type_concept_id integer NOT NULL,
|
||||
|
@ -411,8 +411,8 @@ CREATE TABLE @cdmDatabaseSchema.EPISODE (
|
|||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
CREATE TABLE @cdmDatabaseSchema.EPISODE_EVENT (
|
||||
episode_id bigint NOT NULL,
|
||||
event_id bigint NOT NULL,
|
||||
episode_id integer NOT NULL,
|
||||
event_id integer NOT NULL,
|
||||
episode_event_field_concept_id integer NOT NULL );
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
|
|
|
@ -369,7 +369,7 @@ Occurrences used to construct the
|
|||
condition era.",,No,No,,,,,
|
||||
EPISODE,episode_id,Yes,integer,A unique identifier for each Episode.,,Yes,No,,,,,
|
||||
EPISODE,person_id,Yes,integer,The PERSON_ID of the PERSON for whom the episode is recorded.,,No,Yes,PERSON,PERSON_ID,,,
|
||||
EPISODE,episode_concept_id,Yes,integer,"The EPISODE_CONCEPT_ID represents the kind abstraction related to the disease phase, outcome or treatment.","Choose a concept in the Episode domain that best represents the ongoing disease phase, outcome, or treatment. Please see [article] for cancers and [article] for non-cancers describing how these are defined. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Episode&page=1&pageSize=15&query=)",No,Yes,,,Episode,,
|
||||
EPISODE,episode_concept_id,Yes,integer,"The EPISODE_CONCEPT_ID represents the kind abstraction related to the disease phase, outcome or treatment.","Choose a concept in the Episode domain that best represents the ongoing disease phase, outcome, or treatment. Please see [article] for cancers and [article] for non-cancers describing how these are defined. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Episode&page=1&pageSize=15&query=)",No,Yes,CONCEPT,CONCEPT_ID,,,
|
||||
EPISODE,episode_start_date,Yes,date,The date when the Episode beings. ,Please see [article] for how to define an Episode start date.,No,No,,,,,
|
||||
EPISODE,episode_start_datetime,No,datetime,The date and time when the Episode begins.,,No,No,,,,,
|
||||
EPISODE,episode_end_date,No,date,The date when the instance of the Episode is considered to have ended.,Please see [article] for how to define an Episode end date.,,,,,,,
|
||||
|
|
|
Loading…
Reference in New Issue