What is the most efficient way to create this trigger in Postgres.
I'll present below a very simplified example to what I need for my purposes, but it is based on the same concept.
Consider, we have got the schema defined below:
CREATE TABLE items (
item_id int4,
part_no int4,
description text);
CREATE TABLE blacklist (
part_no int4,
reason text);
CREATE TABLE matches (
item_id int4,
part_no int4,
reason text);
Then, every time a new item is added, we check if it is on the blacklist (comparing the part_no), and if it is, we create a new entry on the matches table.