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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:51:00+00:00 2026-06-14T14:51:00+00:00

I have a question regarding SQL. I have the following SQL tables (Simplified for

  • 0

I have a question regarding SQL. I have the following SQL tables (Simplified for easy comprehension):

Client(clientId INT PRIMARY KEY)

Product (productId PRIMARY KEY)

Order (orderId PRIMARY, clientId which is foreign key to Client, productId which is foreign key to Product)

I also have a table called Inventory, which is supposed to contain the number of items in stock for each product. The primary key to Inventory is called productId (Primary Key), which references the foreign key in Order.
Unfortunately, when I try to add to the Inventory table, it gives me the following error:

"The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Order_Iventory1". The conflict occurred in database "GestionInventaire", table "dbo.Inventory", column 'productId'."

I want the Inventory tables primary ID (productId) to be the foreign key in Order (productId), which comes from the Product table.

Any help is appreciated! If any further explanation is required I will try to elaborate further.

  • 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-06-14T14:51:01+00:00Added an answer on June 14, 2026 at 2:51 pm

    It depends on how complex your stock information is for each product:

    Storing only the latest set of stock numbers for each product

    If you are simply storing the current stock number(s) for each product (e.g. a one-to-one mapping of Product to Inventory), then there’s no need for Inventory to have it’s own table, it would make more sense to store the number in stock directly in the Product table.

    Whilst there may be a logical division in your code model between the product information and the inventory data, that doesnt necessarily mean its a good idea to store the data in multiple tables unless you’re handling huge amounts of data and performance is becoming an issue. Even if it’s stored in a single table, you can still seperate the data into multiple objects as and when you query it and build your model objects.

    (That’s not to say there aren’t legitimate situations where it might be a good idea to do this, but I wouldn’t consider it unless there were no better alternatives)

    Storing multiple sets of stock numbers for each product

    If on the other hand you’re wanting to store a history of the stock levels (a one-to-many mapping from Product to Inventory) then it would make sense to have an Inventory table, but I’d suggest giving it it’s own primary key and having a foreign key from productID to the Product table.

    e.g. Inventory table containing “InventoryID” (primary key), “ProductID” (foreign key to Product.ProductID) and whatever columns you need to store the stock numbers.

    Why Foreign key to Order table?

    Either way it doesn’t really make any sense for Inventory.productID to be a foreign key to Order.productID, since the stock is related to a product, not an order (unless you’re doing live calculations based on the quantities in and out in which case the structure would be a bit more complex).

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

Sidebar

Related Questions

I have a very general question regarding the use of LINQ vs SQL to
I have a question regarding a race condition scenario. The question: Consider the following
I have a question regarding locking in TSQL. Suppose I have a the following
I have a couple of question's regarding the following project. *Scott, Recently some developers
I have a question regarding left join on SQL: I would like to know
Me and my colleagues have a question regarding SQL Server 2008 query length and
I have a simple question regarding Enums in Java Please refer to the following
I have a question regarding performance of SQL Server. Suppose I have a table
I have a question regarding LINQ to SQL. I would like to write the
I am new to SQL and I have a question regarding table relationships. Currently,

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.