When to use triggers in Salesforce
Triggers are used to perform immediate actions based on previous action.
Example: field update
A trigger is Apex code that executes before or after specific Data Manipulation Language (DML) events occur, such as before object records are inserted into the database, or after records have been deleted.
trigger triggerName on ObjectName (trigger_events)
where trigger_events can be a comma-separated list of one or more of the following events: