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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:51:17+00:00 2026-05-13T21:51:17+00:00

My application is storing some data in SQL Table called Transactions. Users are able

  • 0

My application is storing some data in SQL Table called Transactions. Users are able to sell something from Client1 to Client2 and then Client2 has it. I am storing it in a table the following way:

Client 1 | Buy  | Something | Price  | External |
Client 1 | Sell | Something | Price2 | Client 2 |
Client 2 | Buy  | Something | Price2 | Client 1 |

First Client1 bought it (brought it in or just has it for all it matters). Then he sells it to another client.

And all that is fine, it works but my application has a short time when it doesn’t check if Client 1 still has what it claims to have (when data is loaded into gui).
So if 2 users would make run for it it’s possible that product from Client1 could be sold multiple times. Most likely it won’t happen since my users tend to share their work on what they are doing but there’s always BUT…

How to prevent this? Would simple select query check just before insert transaction be sufficient or should this be done differently? (I can imagine situation when multiple people make run for it and some would succeed). How is this handled in real world situations on heavy systems? Like when you pick money from one bank account with 2 cards from 2 different CashMachines (although i believe they would just let balance go under 0 in this case even if it wouldn’t be allowed).

So what options do I have? What is your take on this?

  • 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-13T21:51:17+00:00Added an answer on May 13, 2026 at 9:51 pm

    I assume this is not a real inventory tracking system, where the database merely record real world events, but instead is a some virtual auction or market place sort of application, where ‘reality’ is whatever the application believe it is.

    If you only keep history, you’ll never have the current state. W/o a current state, you can’t make efficient correctness decisions. So keep a current state. Have a table of items and their current owner. The problem you ask then become a simple problem of ‘How to I prevent a lost update?’ or ‘How do I prevent a blind write’? (ie. a write-write conflict) and the answer is well known in database application: use optimistic concurrency control.

    For a detailed discussion of how to use Optimistic Concurrency with C# and SQL, see Optimistic Concurrency (ADO.NET).

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

Sidebar

Related Questions

Imagine a web-application storing some data-resource with some id which stores three attachment (e.g.
My application is storing location data from GPS inputs. When importing a GPX file,
Hey guys, I have an application that I want to display some data from
I have a web application that loads some 50 tables from SQL Server into
For an ASP.Net MVC application, I'm interested in storing some views and/or partial views
I want to build a security related application. I would be storing some important
Wordpress, for example, has a table with name => value rows for storing application-wide
In a winforms application i 'm storing one Wingdings char in a SQL Server
In C# ASP.NET MVC application I use Link to SQL to provide data for
I am migrating data from a Oracle on VMS that accesses data on SQL

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.