A pice of apex logic is executed based on DML operations like, Before Insert After Insert Before Update After Update Before Delete After Delete Before Undelete After Undelete use trigger.new for latest data as list of sObjects trigger.old for previous data as list of sObjects trigger.newMap for latest data as map of Id and data trigger.oldMap for old data as map of id and data
it's an easy way to learn/migrate to salesforce.