Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3400404
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:53:19+00:00 2026-05-18T04:53:19+00:00

I have been enforcing business rules in both my application tier (models) and my

  • 0

I have been enforcing business rules in both my application tier (models) and my database tier (stored procedures who raise errors).

I’ve been duplicating my validations in both places for a few reasons:

  1. If the conditions change between
    when they are checked in the
    application code and when they are
    checked in the database, the
    business rule checks in the database
    will save the day. The database
    also allows me to lock various
    records in a simpler manner than in
    my application code, so it seems
    natural to do so here.
  2. If we have
    to do some batch data
    insertions/updates to the database directly, if I route
    all these operations through my
    stored procedures/functions which
    are doing the business rule
    validations, there’s no chance of me
    putting in bad data even though I lack the protections that I would get if I was doing single-input through the application.
  3. While
    enforcing these things ONLY in the
    database would have the same effect
    on the actual data, it seems
    improper to just throw data at the
    database before first making a good
    effort to validate that it conforms
    to constraints and business rules.

What’s the right balance?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:53:20+00:00Added an answer on May 18, 2026 at 4:53 am

    You need to enforce at the data tier to ensure data integrity. That’s your last line of defense, and that’s the DBs job, to help enforce its world view of the data.

    That said, throwing junk data against the DB for validation is a coarse technique. Typically the errors are designed to be human readable rather than machine readable, so its inefficient for the program to process the error from the DB and make heads or tails out of it.

    Stored Procedures are a different matter. Back in the day, Stored Procedures were The Way to handle business rules on the data tiers, etc.

    But today, with the modern application server environments, they have become a, in general, better place to put this logic. They offer multiple ways to access and expose the data (the web, web services, remote protocols, APIs, etc). Also, if your rules are CPU heavy (arguably most aren’t) it’s easier to scale app servers than DB servers.

    The large array of features within the app servers give them a flexibility beyond what the DB servers can do, and thus much of what was once pushed back in to the DBs is being pulled out with the DB servers being relegated to “dumb persistence”.

    That said, there are certainly performance advantages using Stored Procs and such, but now that’s a tuning thing where the question becomes “is it worth losing the app server capability for the gain we get by putting it in to the DB server”.

    And by app server, I’m not simply talking Java, but .NET and even PHP etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have been having an issue sine using the HABTM relationship in models instead of
Have been trying to get a fresh, just created rails application to work on
Have been trying to encrypt an xml file to a string so that I
Have been working on this question for a couple hours and have come close
Have been looking on some tutorials for drawing canvas using SurfaceView, but the only
Have been reading about async and tasks and been attempting to convert the CopyFileEx
Have been searching how to convert a dictionary to a string. But the results
Have have been trying to make a validator for my xml files. I have
I have been tracking emails for years using a "beacon" image and for those
I have been working with SQL Server as a Developer a while. One thing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.