 ALTER TABLE oqmif.exposure_model ADD CONSTRAINT oqmif_exposure_model_owner_fk
 FOREIGN KEY (owner_id) REFERENCES admin.oq_user(id) ON DELETE RESTRICT;
 
+ALTER TABLE oqmif.exposure_model ADD CONSTRAINT oqmif_exposure_model_input_fk
+FOREIGN KEY (input_id) REFERENCES uiapi.input(id) ON DELETE RESTRICT;
+
 ALTER TABLE riski.vulnerability_model ADD CONSTRAINT
 riski_vulnerability_model_owner_fk FOREIGN KEY (owner_id) REFERENCES
 admin.oq_user(id) ON DELETE RESTRICT;
+
+ALTER TABLE riski.vulnerability_model ADD CONSTRAINT
+riski_vulnerability_model_input_fk FOREIGN KEY (input_id) REFERENCES
+uiapi.input(id) ON DELETE RESTRICT;
 
 ALTER TABLE hzrdr.hazard_map
 ADD CONSTRAINT hzrdr_hazard_map_output_fk

CREATE TABLE oqmif.exposure_model (
    id SERIAL PRIMARY KEY,
    owner_id INTEGER NOT NULL,
    name VARCHAR NOT NULL,
    description VARCHAR,
    -- e.g. "buildings", "bridges" etc.
    category VARCHAR NOT NULL,

    -- area type
    area_type VARCHAR NOT NULL,
    -- area unit
    area_unit VARCHAR NOT NULL,

    -- contents cost type
    coco_type VARCHAR NOT NULL,
    -- contents cost unit
    coco_unit VARCHAR NOT NULL,

    -- retrofitting cost type
    reco_type VARCHAR NOT NULL,
    -- retrofitting cost unit
    reco_unit VARCHAR NOT NULL,

    -- structural cost type
    stco_type VARCHAR NOT NULL,

CREATE TABLE riski.vulnerability_model (
    id SERIAL PRIMARY KEY,
    owner_id INTEGER NOT NULL,
    -- Associates the risk vulnerability model with an input file
    input_id INTEGER,
    name VARCHAR NOT NULL,
    description VARCHAR,
    imt VARCHAR NOT NULL CONSTRAINT imt_value
