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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:56:14+00:00 2026-05-17T19:56:14+00:00

I have two tables in my application. The first one, Sections, stores content for

  • 0

I have two tables in my application. The first one, Sections, stores content for a specific section of an online publication. This contains (among other things) the section title and a field CurrentRevisionId (FK).

A second table, Revisions, stores different revisions of that content. It has PK RevisionId field (the FK above, used to denote current revision), the HTML content itself, and SectionId (FK), specifying which Section the revision belongs to.

So basically I’ve got these two FKs pointing to each other. When I create a new Section, the child entity CurrentRevision is also populated with that content. But the InsertOnSubmit fails with this error:

The INSERT statement conflicted with the FOREIGN KEY constraint “FK_Sections_Revisions”. The conflict occurred in database “xxxx”, table “xxxx.Sections”, column ‘SectionID’. The statement has been terminated.

My guess is that it can’t simultaneously create both rows and populate them with each other’s PKs.

Should I insert the Section first, then the Revision (along with Section’s PK), and then update the Section with the Revision PK? Or is there a better / more elegant solution to this?

EDIT: I’ve attached a screencap of the two tables with their relationships. Each Section has many Revisions (FK SectionID inside of Revisions table). Additionally, there is a one-to-one relationship where the CurrentRevisionId field in Section points to the revision which is “current”. This “current” revision is where the application pulls the HTML from. Hope that clears things up a bit.

alt text

  • 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-17T19:56:15+00:00Added an answer on May 17, 2026 at 7:56 pm

    You can’t have FK’s from 2 tables pointing at each other; it makes no sense.

    If you are trying to model a many-to-many relationship, then you will need to create a mapping table inbetween the two tables. It will contain (at a minimum) two Foreign Keys, one to each of your 2 tables primary keys.

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

Sidebar

Related Questions

I have two tables, one that contains volunteers, and one that contains venues. Volunteers
I have an application that has two threads. The first one (the main thread)
I have two models/tables in my Rails application: discussions and comments. Each discussion has_many
I have a database framework where I have two tables. The first table has
I'm using Lua inside a C application, and I have two tables. I want
I have two tables that are joined together. A has many B Normally you
I have two tables, Book and Tag , and books are tagged using the
We have two Tables: Document: id, title, document_type_id, showon_id DocumentType: id, name Relationship: DocumentType
I have two tables, both with start time and end time fields. I need
I have two tables containing Tasks and Notes, and want to retrieve a list

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.