how to write a trigger to update a master table?