When to use Database Triggers ?

What are Database Triggers ? A Database trigger is an SQL code which is made to run just before or after a certain event. That event could be an INSERT, UPDATE or a DELETE query on a particular database table. Thus a trigger is used to automate some of the events on your server/site/application. Examples of some Database triggers Sync user details from one table to another when a user updates them Geocode users location and store them in a separate table Maintaing log of certain events e.g. a product addition, updation or deletion (In this case we wish to know who did the change) When to use Database triggers There are few pros and cons about using database triggers. Pros: Yes they can automate quite a lot of activities For things like maintaining logs if you are doing this through your code then most probably you need to add the piece of code in a number of files. e.g. If you are maintaing a log about article updates then there may...
Read More