I suggest readings.asset_code be mandatory, and if a FK relationship is desired, add a NULLable asset_id column.
@@ -511,7 +511,7 @@ CREATE INDEX fki_asset_messages_fk2
-- a software or anything that generates data that is sent to FogLAMP
CREATE TABLE foglamp.readings (
id bigint NOT NULL DEFAULT nextval('foglamp.readings_id_seq'::regclass),
- asset_code character varying(50), -- The provided asset code. Not necessarily located in the
+ asset_code character varying(50) NOT NULL, -- The provided asset code. Not necessarily located in the
-- assets table.
read_key uuid UNIQUE, -- An optional unique key used to avoid double-loading.
reading jsonb NOT NULL DEFAULT '{}'::jsonb, -- The json object received
