Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...SQL Triggers and ArchivingSQL Triggers and Archiving
Previous
 
Next
New Post
6/19/2009 8:46 AM
 

I've been wondering about the use of SQL triggers to capture table data and store it in a log before it's overwritten.

One thread I found which mentioned it (very) briefly but was an interesting read is this one - http://www.dotnetnuke.com/Community/Forums/tabid/795/forumid/118/threadid/250006/scope/posts/Default.aspx

Look at the DNN database, there are no triggers at all.  From over 2 years of adding various 3rd party modules I was a little surprised though I'm not a developer so it does raised some questions in my mind.

Are there issues with using triggers that I mightn't be aware of?

I would have thought log files, deleted items etc might have been handled via triggers but it looks like this isn't the case. Are there advantages in using queries and stored procedures instead of this?

 
New Post
6/19/2009 9:07 AM
 

The general rule of thumb for triggers is "Triggers are great......Don't Use Them"   This is because triggers work automatically regardless of what you want to do, therefore the more triggers in your DB the more work the DB is doing and the more complex.  Meaning when you want to debug a problem DB, you find using trigger starts to become a nightmare.

But still, if you use triggers responsibly they can be a great help!!

 

 
New Post
6/19/2009 9:52 AM
 

Interesting thread.

 
New Post
6/19/2009 10:08 AM
 

Ok, not surprising really from what I'm finding... or not finding - searching here for 'SQL trigger' turned up a single post.

What I'm thinking about is looking at a before trigger on updating to table(s) that store things like contact details... so a history of changes can be kept.

I'm guessing the alternative would be to insert to a log table at the same time as updating the main data table.  This might be a better way to go if I can't be sure what 'side effects' triggers might have in the future - even if they are simple ones for storing an archive log (and knowing the DNN guys opted for this sort of thing too).

 
New Post
6/19/2009 11:12 AM
 

there are a couple of good reasons for not using triggers

1. not all databases support triggers, so it would make it harder to create non-sql server/oracle versions of the core/modules. It's better to keep this logic in the businss layer.

2. if a trigger fails it can cause an action on a table to fail i.e. a trigger to log changes to a table may cause the change to fail.

However, for me the biggest problem with triggers is 3rd party developers using them and causing core upgrades to fail (i see this on modules that try to do cross-portal logins via triggers on the users or portals tables). If the core attempts to alter a table (e.g. to add columns) the existance of a trigger can cause that to fail causing the whole upgrade to fail. Whilst it's fine to add triggers to any tables your own module creates , if you add a trigger to a core table you're asking for trouble.

Cathal


Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...SQL Triggers and ArchivingSQL Triggers and Archiving


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out