Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

As an example, lets say I have a forum application and for every topic that is created, I have a trigger that fires a database function creating a post.(lets assume we have a topics table and a post table)

I know these things can be quite circumstantial, but generally, do simple tasks like this belong in triggers/functions, or should they just be done in the application code?

As for updating views and replies I was thinking of offloading them to a queue, since the systems functionality doesn't really depend on them.

share|improve this question

closed as not constructive by Mark Storey-Smith, Jon Seigel, dezso, Max Vernon, RolandoMySQLDBA May 17 '13 at 20:15

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
This is an extremely subjective question and there a lot of conflicting views. I agree with the views expressed in Jeff Atwood's blog post from 2004: Who Needs Stored Procedures, Anyways?, and his 2005 semi-followup. Many (most?) DBAs would disagree, and there's a lot of feedback from them in the comments for that post. –  Nathan Jolly May 16 '13 at 3:47
    
Thanks, just wanted some input and you guys have helped. I realize after last night how subjective this is without much more information. Anyway thanks again. –  Jaigus May 16 '13 at 16:29
add comment

1 Answer 1

up vote 0 down vote accepted

Triggers are problematic because they tend to get forgotten about. I only ever use triggers for auditing purposes such as updating a "last updated datetime" column. Stored procedures and functions can be used at any time since they are called directly by processes wishing to modify data -- as opposed to triggers that are fired as the result of data being changed.

If you are building queues to do some of the work, I suggest you also use queues to create your posts as well.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.