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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:59:21+00:00 2026-05-15T10:59:21+00:00

Let’s say, we have these SQL tables: [Articles] bill int (pkey) arti int (pkey)

  • 0

Let’s say, we have these SQL tables:

[Articles] 
bill   int         (pkey)
arti   int         (pkey)
name   varchar(50) 

[Bills]
bill   int         (pkey)
fdate  date
uid    int

Let’s suppose we have a list of items on a grid, representing a bill:

--------------------------------------------------------------
Id[      15]  Date [01-01-1980]
User [pepe]

Code   Name
----------------------------
1      Something
2      Article name
3      lolololololoolo
4      datadatdatdatdata
5      datadatdatdatdata
--------------------------------------------------------------

So, we have a header with, an id, user, date, etc. And, then, the grid filled with items.

Both tables will be saved at the same time when the user decides (a save button). And, the user can also see a previous bill and modify it. So, what’s better?

  1. Loop the items and make a query to decide: if exists is an INSERT, else, is an UPDATE.
  2. Delete All the items (by bill id) and then, do all INSERTS.
  • 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-15T10:59:22+00:00Added an answer on May 15, 2026 at 10:59 am

    If you only have the two choices it will mostly depend on your requirements and the use cases you want to optimize for. That said you should consider the following

    Performance

    In Option 1 Deleting all of the articles will take longer.

    In option 2 Adding no articles to an bill with 10 article will take the same about of time as adding 10 articles to a bill with no articles.

    Auditing

    Option 2 is very difficult to audit

    Concurrency
    Assuming no concurrency detection in application

    Two users open the bill at the same time. Each user adds adds five articles and hits save.

    In option 1 you’ll end up with 10 articles.
    In option 2 you’ll end up with five.

    I can’t say which is right.

    Transaction Performance

    When adding articles to existing bills Transactions will take longer than need be in option 2. This increases the likelihood of deadlocks for that use case.

    Save failures without transaction support this assumes your app doesn’t use transactions.

    In Option 1 there’s a potential that new articles may be lost and deleted articles that should have been deleted aren’t

    In Option 2 there’s a potential for all articles to be lost

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

Sidebar

Related Questions

Let's say I have two tables orgs and states orgs is (o_ID, state_abbr) and
Let's say I have window.open (without name parameter), scattered in my project and I
let's say I have a select list as follows: <select name='languages'> <option value='german'>German</option> <option
Let's say I have 2 functions: void function1(int *ptr) { printf(%d, *ptr); } and
Let's say we have: @Entity public class Order { @Id private int id; @OneToMany(mappedBy=order)
Let's say I don't have photoshop, but I want to make pattern files (.pat)
Let's say I have a method in java, which looks up a user in
Let me explain best with an example. Say you have node class that can
Let's say I have a table with a Color column. Color can have various
Let's say that I have a SQLite database that I create in a separate

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.