   REFERENCES admissions(hadm_id);
 
 -----------------
---ICUSTAYEVENTS--
------------------
-
--- subject_id
-ALTER TABLE ICUSTAYEVENTS
-ADD CONSTRAINT icustayevents_fk_subject_id
-  FOREIGN KEY (subject_id)
-  REFERENCES patients(subject_id);
-
--- hadm_id
-ALTER TABLE ICUSTAYEVENTS
-ADD CONSTRAINT icustayevents_fk_hadm_id
+--ICUSTAYS--
+-----------------
+
+-- subject_id
+ALTER TABLE ICUSTAYS
+ADD CONSTRAINT icustays_fk_subject_id
+  FOREIGN KEY (subject_id)
+  REFERENCES patients(subject_id);
+
+-- hadm_id
+ALTER TABLE ICUSTAYS
+ADD CONSTRAINT icustays_fk_hadm_id
   FOREIGN KEY (hadm_id)
   REFERENCES admissions(hadm_id);
 

ALTER TABLE DATETIMEEVENTS
ADD CONSTRAINT datetimeevents_fk_icustay_id
  FOREIGN KEY (icustay_id)
  REFERENCES icustayevents(icustay_id);


-----------------

ALTER TABLE IOEVENTS
ADD CONSTRAINT ioevents_fk_icustay_id
  FOREIGN KEY (icustay_id)
  REFERENCES icustays(icustay_id);

-- cgid
ALTER TABLE IOEVENTS
