Triggers Edit

A trigger is procedural code that is automatically executed by the RDBMS in response to certain events on a particular table in a database. In simple terms, a trigger is code that is put into a database system that is made to “raise a flag” when data reaches a certain point. For example, in a retail store, most of the inventory is done using a complex database system. In a big store with a lot of products, it is hard to keep track of the entire inventory. The database makes this process easier to keep track of everything, but ordering still needs to be done to items getting low. This is where the trigger steps in. When an item is scanned, it goes through a sequence and takes one, or how every many were scanned, out of the system. A trigger is set into the system, telling the system what the minimum amount of inventory a certain item can have before reorder. When the inventory number gets to that set number, the database automatically re-orders that product. Instead of having to do it by hand, the computer saves a bunch of time and frustration. There are two different kinds of triggers. There are “row triggers” and “statement triggers”. Row triggers can be used to define an action for every row of a table. Statement triggers are used only one time for each insert, update, or delete statement. Triggers can be used, or conducted, three different times. “Before” triggers are executed before the statement. “After” triggers are the opposite, as they are executed after the statement. There are also “instead of” triggers. These triggers are executed in place of the statement, buy are limited to the views. There are three triggering events that can cause these triggers to take place, or execute. The first trigger happens when an insert statement takes place. If any given number with a trigger surpasses the minimum or maximum number (set by a certain number), a trigger is thrown and the system is alerted. The next trigger happens when an update statement takes place. Again, if numbers are changed that cause the trigger to execute, the system is again alerted. Very similar to that of the insert is when a delete statement takes place. If the numbers are changed, and go above or below that of the set limit, a trigger is executed, and the system finds out about it. Though triggers are a relatively simple event, they are extremely important when working with a database system. When working with retail inventory, for example, it is very important to know when a product is getting low in inventory and the triggers let them know to order more. These trigger statements help in making life easier for many operations today.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.