In: Computer Science
SQL Assignment:
Provide a made-up scenario about when a database trigger could be used. There is no need to provide the syntax to create the trigger, as this would differ depending upon the actual design of the database. Only provide the scenario of when a trigger could be used.
A database trigger is a code that is automatically executed when any DML operation performed on any Table of View in the Database. The trigger is commonly used for maintaining integrity information on the database.
Several DML (Data manipulation languages) operations for adding (inserting), deleting, and modifying (updating) data in a database in such scenarios, we need to track the Log's in our system for such operations and triggers is the key option to use and peruse our need.
Suppose you wanted to save the Logs of user transactions in the banking system i.e. Account number, amount, when Amount Credited, Debited, who Credited, who debited, Date of time for Credit/Debit, IP Address from where such operation did so such essential Log is needed later.
Take Example for Any user debited amount but due to some network amount debited from users' accounts but not credited on other hand so here Logs will be the key solution and those log entries are available because of the use of the Trigger.
Here if we used Triggers, then respected data will be available and easily we can track the issue and will resolve it.
Another way there is an annual survey where these logs are very important so in such scenarios Triggers is useful.
Thanks.