 -- "site" table, and I merged it with the "asset" table.  But this leaves me
 -- without a place to store, in the future when it will probably needed, the
 -- aggregated loss value per site; the aggregated value is useful for plotting
--- purposes.
+-- purposes. Maybe a "site" table would be useful in this case?
 CREATE TABLE uiapi.loss_map_data (
     id SERIAL PRIMARY KEY,
     loss_map_id INTEGER NOT NULL, -- FK to loss_map.id
-    asset_ref VARCHAR,
+    asset_ref VARCHAR NOT NULL,
     loss_mean float,
     loss_std_dev float,
     loss_value float,



-- Loss map data.

-- Design decision: store both probabilistic and event based loss map in the
-- same tables (with some checks for consistency)

            OR (loss_value IS NOT NULL AND loss_mean IS NULL AND loss_std_dev IS NULL))
) TABLESPACE uiapi_ts;
SELECT AddGeometryColumn('uiapi', 'loss_map_site_data', 'site', 4326, 'POINT', 2);


-- Loss asset data.
