Where Does the Business Logic Go?


September 29, 2009 by Mike Hillwig

A few years ago, when I was at the utility company, we were implementing the new customer management system. This was the first time I had ever seen a system that implemented all of the business logic in the database. Most of my experience was with the logic being on the client application.

Which one is better? I really don’t know.

In the case of the utility company, the system was new, and this was one of the first large implementations of the application. We were rolling out changes almost nightly. If we would have to have upgraded the client nightly, it would have been a pain. Instead, we applied it to a single database server, and the business logic was taken care of.

At my last company, all of the business logic was in the client application, and rolling out a service pack or hot fix to the application was a pain. Not only would our hundreds of Boston users have to be upgraded, but we’d have to upgrade our Citrix servers as well. As well as we’d plan it, it was never as easy as one might hope.

In my current company, we don’t have serious desktop management, and our ERP system has business logic in both places. We could upgrade the desktops in a few hours if necessary. Most of heavy lifting is fortunately done in the database. This thing has nested stored procedures several layers deep.

Our document management system, on the other hand would be a nightmare. All of the business logic is done by the desktop application. And it’s installed all over the company. I cringe at the thought of customizing that application. Fortunately, we haven’t had to.

I go back to the question of where the business logic should live? I like having it in the database because then I can control it. It typically makes patching easier. At the same time, it’s  a performance hit. There are more stored procedures and triggers. And yet, my database servers are typically more powerful than user laptops.

I have a feeling this is almost a religious debate, and we’ll never have a “right” answer. Your comments should be interesting, and I look forward to reading them.

  • for me it’s a pretty simple answer.
    the data logic goes into the db
    the app logic goes out of the db.

    data logic is logic to keep data consistent because data is always accessed from multiple sources.
    app logic is doing weird business stuff with that data.

    data logic would be unique mail address.
    app logic would be person can have only 1 main mail since in other apps accessing the same data this may not be so.

  • I missed the Pre-Con due to work but atdtened on Saturday. Buck Woody’s keynote was superb as was the opportunity to meet some vendors. A great day and hopefully more UK SQLSaturdays will be organised. The demand is definitely there.

  • I’ve been reading Marcus’ ebook and it is fantastic, I hope to be at one of the future conferences he does. Thank you for the other tips, I will be subscribing to your posts via email, this is great stuff.

  • Satte upp ett helt nytt inlägg där vi kan diskutera här, men jag har nÃ¥gra följdfrÃ¥gor:1. SÃ¥ här mÃ¥nga olika källor, vad tycker du om dem? De är sunnitiska hela högen.2. Vad skulle du tycka om en person som sÃ¥rade, angrep och attackerade en dam, som var vÃ¥r Profets dotter? Ni brukar ju ta illa upp när Aisha blir angripen, är det inte värre att angripa Profetens kött och blod?3. Vems sida tycker du man ska välja? Profetens eller hans vänners?