Constraint vs. Trigger

Have you ever wondered which one to choose if you want constraint(s) to be forced on data? You can achieve your goal by using Triggers or Constraints (or even both). But the questions is which one to choose, and which one is better to use? Shall one go with Constraint all the time or pick Triggers every now and then? The relief is that there is a simple answer to that. Try to use constraints if you can. Constraints are “closer” to databases. Constraint are relational restriction you are setting for your data, and if you are using a relational database it is always best to use them. As all we know databases nowadays do more than just storing data and retrieving them, they perform optimization on queries as well. Defining constraint in your database, which is a relational principle, will give another chance for your database to deal with performance issues.

For more discussion head to this page: Performance consideratinos for Triggers vs Constraints

Leave a Reply

Your email address will not be published. Required fields are marked *