1 Can you use some real business examples of why a database
1. Can you use some real business examples of why a database trigger may be needed in visualizing the difference between triggers and procedures. Examples may be: tracking database access by user and time and keeping audit trails on changes to sensitive data such as payroll.
2. How and why might a trigger be used in place of a check constraint to check values?
Solution
1. The basic difference between a trigger and stored procedure is its calling mechanism. A trigger is a special procedure which gets called at a condition in INSERT,UPDATE or DELETE operation whereas the stored procedures are explicitly called. In your example too suppose a db is accessed by a user then to use a procedure it must be called explicitely to update the time where as trigger will get automatically called and it will do its work. For audit purpose also we use triggers.
2. The triggers can be used to work as a contraint but the main difference in using a normal constraint is the contraints will be done on relational ways where as the triggers handles the data non-reltional basis.
