PostgreSQL Trigger Example
Triggers can be handy at times, but I tend to stay away from them as long as possible, because they can cause performance degradation at times, plus I tend to forget they're hiding behind the scenes, doing random things. In any case, let's see how you can create a simple trigger in Postgres. Steps Create a lookup table Create a parent table Create a child table Create trigger function to convert lookup value to handle Inserts/Updates/Deletes For inserts and updates, convert lookup value to look up id Create trigger Test .. by running several 1000 inserts, updates and deletes Replace myschema with the name of your schema -- Create Lookup Table create table myschema.lookuptable ( lookupid integer not null , lookupvalue varchar ( 50 ) not null , constraint pk_lookuptable primary key (lookupid) ); insert into myschema.lookuptable (lookupid, lookupvalue) values ( 1 , 'hello' ), ( 2 , 'bonjour' ), ( 3 ...