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

  • Home
  • SEARCH
  • 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 7693447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:05:27+00:00 2026-05-31T21:05:27+00:00

The MSDN claims that the order is : Child table: delete records. Parent table:

  • 0

The MSDN claims that the order is :

  1. Child table: delete records.
  2. Parent table: insert, update, and delete records.
  3. Child table: insert and update records.

I have a problem with that.

Example : ParentTable have two records parent1(Id : 1) and parent2(Id : 2)

ChildTable have a record child1(Id : 1, ParentId : 1)

If we update the child1 to have a new parent parent2, and then we delete parent1.

  1. We have nothing to delete in child table
  2. We delete parent1 : we broke the constraint, because the child is still attached to parent1, unless we update it first.

So what is the right order, and is the MSDN false on the subject?

My personnals thoughts is

  1. Child table: delete records.
  2. Parent table: insert, update records.
  3. Child table: insert and update records.
  4. Parent table: delete records.

But the problem is, with potentially unique constraint, we must always delete the records in a table before adding new… So I have no solution right now for commiting my datas to my database.

Edit : thanks for the answers, but your corner case is my daily case… I opt for the ugly solution to disabled constraint, then update database, and re-enabled constraint. I’m still searching a better solution..

  • 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-31T21:05:28+00:00Added an answer on May 31, 2026 at 9:05 pm

    Doesn’t your SQL product support deferred constraint checking ?

    If not, you could try

    Delete all child records – delete all parent records – insert all parent records – insert all child records

    where any UPDATEs have been split into their constituent DELETEs and INSERTs.

    This should work correctly in all cases, but at acceptable speeds probably in none …

    It is also provable that this is the only scheme that can work correctly in all cases, since :

    (a) key constraints on parent dictate that parent DELETES must precede parent INSERTS,
    (b) key constraints on child dictate that child DELETES must precede child INSERTS,
    (c) FK dictates that child DELETES must precede parent DELETES
    (d) FK also dictates that child INSERTS must follow parent INSERTS

    The given sequence is the only possible one that satisfies these 4 requirements, and it also shows that UPDATEs to the child make a solution impossible no matter what, since an UPDATE means a “simultaneous” DELETE plus INSERT.

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

Sidebar

Related Questions

I have created a Custom STS using the claims walkthrough here: http://msdn.microsoft.com/en-us/library/ff955607.aspx . I
MSDN says that you should use structs when you need lightweight objects. Are there
MSDN displays the following for CreatePatternBrush: You can delete a pattern brush without affecting
MSDN states that String.Intern retrieves the system's reference to the specified String and String.IsInterned
MSDN docs say that only value types need boxing, but this does not apply
MSDN says that public static members of System.Windows.Application are thread safe. But when I
I was looking for extension methods and stumbled in to a function that claims
MSDN states that gacutil.exe is not safe to use for production servers . Is
MSDN says that ParallelEnumerable.GroupBy groups in parallel the elements of a sequence according to
MSDN has no information on the order preserving properties of data structures. So I've

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.