Home > Ask the Data management / BI Experts > Questions & Answers > Three rules of thumb for triggers
Ask The Data Management Expert: Questions & Answers
EMAIL THIS

Three rules of thumb for triggers

Craig Mullins, Years 2005-2006 EXPERT RESPONSE FROM: Craig Mullins, Years 2005-2006

Pose a Question
Other Data Management Categories
Meet all Data Management Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 18 October 2004
We have had a lot of discussions about triggers. Some say it's better to write the code in an application program and some say it's better with a trigger.

If we should use either one, when should we use it? Some say -- don't use AFTER-triggers or not on high transaction applications. Is that true?

>
The general rules of thumb I advocate for triggers are as follows:

1. Favor triggers when data modifications can be done outside the control of planned applications. Doing so will enforce your integrity constraints in the triggers that would not be enforced otherwise.

2. Triggers are less efficient than constraints. If you can accomplish the same effect with referential, unique or check constraints do so, as it will be more efficient.

3. If all modifications to the data are done through transactions, performing the code in the application logic instead of a trigger will likely be more efficient.

As with most things, your exact mileage will vary. In other words, you should investigate using triggers where it makes sense given the business rules that apply to your data. For applications with very high transaction rates be sure to thoroughly test the impact of triggers on your system before committing to them.

Triggers provide many potential benefits for enhancing DB2 databases. With triggers your DB2 tables can become active -- meaning that DB2 will take action implicitly as the data in the database is modified. Triggers are a very powerful way to enhance the data integrity of your DB2 databases.

Still, keep these additional cautions in mind:

- When triggers are added to a table, they are not effective on existing data.

- Triggers are not fired for the LOAD Utility (except for the LOAD SHRLEVEL CHANGE).

Editor's note: Do you agree with this expert's response? If you have more to share, post it in one of our discussion forums.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
IBM DB2 management
How to select an MPP database: DB2 vs. Teradata
What are the top database management systems (DBMS)?
Are there benefits to using both Teradata and a DB2 database?
Tips for evaluating top database management systems and choosing a small DBMS
Exec explains IBM's Information On Demand (IOD) initiative
IBM DB2 9 Fundamentals certification (Exam 730): Sample questions about tables, Part 7
IBM DB2 9 Fundamentals certification (Exam 730): Sample questions about tables, Part 6
IBM DB2 9 Fundamentals certification (Exam 730): Sample questions about tables, Part 5
DB2 basics
IBM DB2 basics

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice

About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2005 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts