SQL Server Database Design – One Table or Duplicate Table with Different Dependencies

database-designentity-frameworksql server

Disclaimer: I'm new to database modeling so I apologize in advance if the question is unclear or causes any confusion.

I am using .NET Entity Framework and have the following tables:

ERD

An Order can have multiple Items, but Item itself is not existence dependent on Order. That said, should I have two separate tables for Item, e.g. InventoryItem and OrderItem? If not, how should I manage the relationship?

Any help is appreciated!

Best Answer

Yes, definitely separate them as they represent different concepts. An invevtory item is a count of stock on hand and mirrors physical artefacts. An order item is a clause in a contract of sale. The order item may or may not be honoured, amended or have a different product substituted. It only gains anything like physical representation when a shipment and corresponding shipment items are created.

Each of these "item" tables will have a foreign key to a Product table. Each represents the intersection of Product and some header table resolving a many-to-many relationship.