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 7020847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:22:19+00:00 2026-05-27T23:22:19+00:00

OK, so let start from the beginning. For instance, I’m developing some big project.

  • 0

OK, so let start from the beginning. For instance, I’m developing some big project. It isn’t a secret for all of us that such projects contains a lot of common logic. Say, for example, that some online shop order must have some items and sum of prices of all items must be exactly 1000. So, I implement this logic in MVC3 web application and do validation on order. If there are issues it will tell user about issues and ask him to repost the form.

But project has another important part. It’s DB. Here I can also wrap this validation logic in some stored procedure and add orders only through this proc to be sure that there is no inconsistencies. (Or should I use checks on table to be sure?)

Here’s the stuck I run. It is necessary to dublicate logic in two places to get data integrity. Of course, I may store validation logic only on DB side. But I doubt it will decrease application performance.

I’m sure more experienced guys has a complete and elegant solution for this question.

So, how can I implement logic only in one place?

  • 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-27T23:22:19+00:00Added an answer on May 27, 2026 at 11:22 pm

    Simple answer, not to everyone’s liking

    • Your database will outlast your client code
    • You will have multiple client code bases for your database
    • It’s usual to have validation in several places: would you trust user input from a browser and skip server side validation?
    • Define “validation”: complex business rules or data integrity? If the latter, then it should be the RDBMS’ responsbility

    Edit, about the latter part

    Not all logic needs to be implemented in the database: only logic that will be common to several client code bases. Or you can funnel these common requests through a separate tier/service that deals with it.

    Note, some business logic is based on aggregations or cross-table or whole-table checks that simply are best done in the database

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

Sidebar

Related Questions

Let's start from the beginning: I'm writing an algorithm for a Silverlight application, which
Before I start, let me say that I looked at all the similar questions
Let me start by saying that I do not advocate this approach, but I
Let me start out by saying that I'm not a JavaScript developer so this
Let me start by explaining our set-up: I am working with some contractors. They
Let me start by telling you that I never used anything besides SVN and
First of all let me say thank you to everyone that offered answers...I have
Let me start off by saying that I am completely new with WPF (this
I will try to make myself as clear as possible. Let start from the
Let me start from a real life example: Customer: Alex, just noticed something strange

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.