Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix constraint.sql for mimic-iv-ed PostgreSQL #1659

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions mimic-iv-ed/buildmimic/postgres/constraint.sql
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
SET search_path TO mimic_ed;
SET search_path TO mimiciv_ed;
---------------------------
---------------------------
-- Creating Primary Keys --
---------------------------
---------------------------

ALTER TABLE mimic_ed.edstays DROP CONSTRAINT IF EXISTS edstays_pk CASCADE;
ALTER TABLE mimic_ed.edstays
ALTER TABLE mimiciv_ed.edstays DROP CONSTRAINT IF EXISTS edstays_pk CASCADE;
ALTER TABLE mimiciv_ed.edstays
ADD CONSTRAINT edstays_pk
PRIMARY KEY (stay_id);

ALTER TABLE mimic_ed.diagnosis DROP CONSTRAINT IF EXISTS diagnosis_pk CASCADE;
ALTER TABLE mimic_ed.diagnosis
ALTER TABLE mimiciv_ed.diagnosis DROP CONSTRAINT IF EXISTS diagnosis_pk CASCADE;
ALTER TABLE mimiciv_ed.diagnosis
ADD CONSTRAINT diagnosis_pk
PRIMARY KEY (stay_id, seq_num);

--ALTER TABLE mimic_ed.medrecon DROP CONSTRAINT IF EXISTS medrecon_pk CASCADE;
--ALTER TABLE mimic_ed.medrecon
--ALTER TABLE mimiciv_ed.medrecon DROP CONSTRAINT IF EXISTS medrecon_pk CASCADE;
--ALTER TABLE mimiciv_ed.medrecon
--ADD CONSTRAINT medrecon_pk
-- PRIMARY KEY (stay_id, charttime, name);

--ALTER TABLE mimic_ed.pyxis DROP CONSTRAINT IF EXISTS pyxis_pk CASCADE;
--ALTER TABLE mimic_ed.pyxis
--ALTER TABLE mimiciv_ed.pyxis DROP CONSTRAINT IF EXISTS pyxis_pk CASCADE;
--ALTER TABLE mimiciv_ed.pyxis
--ADD CONSTRAINT pyxis_pk
-- PRIMARY KEY (stay_id, charttime, name);

ALTER TABLE mimic_ed.triage DROP CONSTRAINT IF EXISTS triage_pk CASCADE;
ALTER TABLE mimic_ed.triage
ALTER TABLE mimiciv_ed.triage DROP CONSTRAINT IF EXISTS triage_pk CASCADE;
ALTER TABLE mimiciv_ed.triage
ADD CONSTRAINT triage_pk
PRIMARY KEY (stay_id);

ALTER TABLE mimic_ed.vitalsign DROP CONSTRAINT IF EXISTS vitalsign_pk CASCADE;
ALTER TABLE mimic_ed.vitalsign
ALTER TABLE mimiciv_ed.vitalsign DROP CONSTRAINT IF EXISTS vitalsign_pk CASCADE;
ALTER TABLE mimiciv_ed.vitalsign
ADD CONSTRAINT vitalsign_pk
PRIMARY KEY (stay_id, charttime);

Expand All @@ -41,32 +41,32 @@ ADD CONSTRAINT vitalsign_pk
---------------------------
---------------------------

ALTER TABLE mimic_ed.diagnosis DROP CONSTRAINT IF EXISTS diagnosis_edstays_fk CASCADE;
ALTER TABLE mimic_ed.diagnosis
ALTER TABLE mimiciv_ed.diagnosis DROP CONSTRAINT IF EXISTS diagnosis_edstays_fk CASCADE;
ALTER TABLE mimiciv_ed.diagnosis
ADD CONSTRAINT diagnosis_edstays_fk
FOREIGN KEY (stay_id)
REFERENCES mimic_ed.edstays (stay_id);
REFERENCES mimiciv_ed.edstays (stay_id);

ALTER TABLE mimic_ed.medrecon DROP CONSTRAINT IF EXISTS medrecon_edstays_fk CASCADE;
ALTER TABLE mimic_ed.medrecon
ALTER TABLE mimiciv_ed.medrecon DROP CONSTRAINT IF EXISTS medrecon_edstays_fk CASCADE;
ALTER TABLE mimiciv_ed.medrecon
ADD CONSTRAINT medrecon_edstays_fk
FOREIGN KEY (stay_id)
REFERENCES mimic_ed.edstays (stay_id);
REFERENCES mimiciv_ed.edstays (stay_id);

ALTER TABLE mimic_ed.pyxis DROP CONSTRAINT IF EXISTS pyxis_edstays_fk CASCADE;
ALTER TABLE mimic_ed.pyxis
ALTER TABLE mimiciv_ed.pyxis DROP CONSTRAINT IF EXISTS pyxis_edstays_fk CASCADE;
ALTER TABLE mimiciv_ed.pyxis
ADD CONSTRAINT pyxis_edstays_fk
FOREIGN KEY (stay_id)
REFERENCES mimic_ed.edstays (stay_id);
REFERENCES mimiciv_ed.edstays (stay_id);

ALTER TABLE mimic_ed.triage DROP CONSTRAINT IF EXISTS triage_edstays_fk CASCADE;
ALTER TABLE mimic_ed.triage
ALTER TABLE mimiciv_ed.triage DROP CONSTRAINT IF EXISTS triage_edstays_fk CASCADE;
ALTER TABLE mimiciv_ed.triage
ADD CONSTRAINT triage_edstays_fk
FOREIGN KEY (stay_id)
REFERENCES mimic_ed.edstays (stay_id);
REFERENCES mimiciv_ed.edstays (stay_id);

ALTER TABLE mimic_ed.vitalsign DROP CONSTRAINT IF EXISTS vitalsign_edstays_fk CASCADE;
ALTER TABLE mimic_ed.vitalsign
ALTER TABLE mimiciv_ed.vitalsign DROP CONSTRAINT IF EXISTS vitalsign_edstays_fk CASCADE;
ALTER TABLE mimiciv_ed.vitalsign
ADD CONSTRAINT vitalsign_edstays_fk
FOREIGN KEY (stay_id)
REFERENCES mimic_ed.edstays (stay_id);
REFERENCES mimiciv_ed.edstays (stay_id);
Loading