Tuesday, November 22, 2011

Starting this blog

So I finally was able to find some time to start this blog. I mentioned before that I might do this in the asktom discussion here. This blog will be about database triggers. Oracle database triggers that is. I'm a strong advocate of database triggers. Now hold your horses... I have been using database triggers ever since Oracle7 in the early nineties brought them to us. But I've been using them for a very specific reason, and have been presenting about this ever since. I will blog about this in a very similar way as I blogged about TheHelsinkiDeclaration, by documenting the presentation I have frequently given now at various Oracle related seminars and user group meetings.

Let me present exhibit A, showing that I have been presenting about a particular use-case for using database triggers for quite some time now. Here's the front cover of the 1994 International Oracle User Week (that's how Oracle OpenWorld used to be called in the nineties) conference.

And here's a part of the contents.


Paper #10, "Business Rules: Classification and Implementation (...)". And as you can see I was employed by Oracle back then. Note that Steve (Feuerstein) was already presenting in those days too. Now some of you can already guess what my talk was about. The use-case for triggers that I'm advocating, that is. For those of you who don't, stay tuned, I will explain the use-case and my arguments for it, in the posts that will follow.

So that was (almost) two centuries ago, business rules presentations by T(oon) K(oppelaars)...

Fast forward to this millenium. Here's another TK on triggers in the database:

From http://tkyte.blogspot.com/2006/09/classic-example-of-why-i-despise.html
"Triggers are so abused and so used inappropriately, I'd rather live without them."
"There are no times triggers cannot be avoided. They are purely a convenience that is overused, abused, and improperly used."

And from: http://tkyte.blogspot.com/2007/03/dreaded-others-then-null-strikes-again.html
[on why he doesn't like triggers] "Because I hate being surprised or tricked. And triggers are all about trickery and surprises."

The other "TK" of course is Tom Kyte from asktom.oracle.com. Since you are reading this blog, I"m sure Tom Kyte needs no further introduction. He makes no secret of the fact that he has strong reservations about the database feature called "triggers". And this opinion is wholeheartedly embraced by the PL/SQL community at large. The default response whenever a question on database triggers pops up on  PL/SQL OTN forum is:

"Triggers should be avoided as much as possible."
"Don't use them, they are bad."
"Triggers are considered harmful."

Well excuse me, but I find this general consensus harmful.

At this time I should disclose that I run a company called RuleGen, which is also the name of a product that generates Oracle trigger code to implement business rules.

A year ago I decided to present on why I find this general consensus harmful. And this resulted in a presentation at Hotsos 2011. The title of this presentation is: "Triggers considered harmful, considered harmful". And that's not a typo, no. I'm using the "considered harmful" concept which was introduced by Edsger Dijkstra when he published a paper called "Goto statement considered harmful". And as you can read here, it gave cause to quite some 'follow up' papers with the same "typo" in their titles.

Recently I also delivered this presentation at the BGOUG. And it has been submitted for presentation at the upcoming ODTUG. I'll let you know if it got accepted, so you can attend ODTUG and hear a live version of this blog.

So much for the introduction. Future posts we will go into the details of why I find triggers not harmful at all given they are used for a very specific use-case.




11 comments:

  1. You're right (of course) Toon about there being a time and a place for triggers.

    But then it's similar for the "exception when others" rule that's oft quoted and other such things.

    Even the maligned BCHR is not always meaningless.

    The point being that 95% of the time these things are misused and abused and this causes much more trouble compared to the benefit when used appropriate.

    Never say never, never say always.

    Anyway, I look forward to the series.

    ReplyDelete
  2. I know, I know. Resistance is probably futile in the (almost closed) triggers debate. Yet I have the urge to document, and document well, the one use-case for triggers.
    And in passing so, also explain in detail stuff like mutating table etc.

    ReplyDelete
  3. Toon,

    the mentioned asktom thread made me read Chapter 11 of your book in detail, and that's real great stuff !

    As a mathematician who works as database professional, I also consider triggers not harmful.
    Instead, I use them since V7 and like using them.

    Looking forward to follow this blog,
    Matthias aka Sokrates

    ReplyDelete
  4. Matthias,

    Chapter 11 is even greater stuff, if you read in detail, and understand, all the previous chapters as well ;-).

    T

    ReplyDelete
  5. Toon,

    I enjoyed reading your book. I have a question for chapter 11 regarding the implementation for deferred checking using global temporary table to store constraint violations. I don't know if this is the right place to ask the question.

    Thanks,

    Jason

    ReplyDelete
  6. Toon,
    You make me feel old ;-) mentioning Edsger Dijkstra
    http://nl.wikipedia.org/wiki/Kortstepadalgoritme
    Regards Erik

    ReplyDelete
  7. Erik, welcome to the dinosaur club ;-)

    ReplyDelete
  8. Hey Toon, "goed bezig"/cool ;)

    http://jonathanlewis.wordpress.com/2011/11/29/new-link/

    +edit+
    Oh, no idea why Google decided to use an old account name I never use anymore.
    Perhaps a resounding "Regards, hoek" rings a bell ;)

    ReplyDelete
  9. Hey Martijn!
    Stay tuned. You'll enjoy this, I'm sure.
    Toon

    ReplyDelete