![enter image description here][2]I am working on a database that will create a three-tier structure. The idea is going to look like this:
- 1st level:
Order
table- Primary Key -
OrderID
- Primary Key -
- 2nd Level:
OrderlineItemHeader
table- Primary Key -
OrderID
- Primary key -
OrderLineItemHeaderID
- Primary Key -
- 3rd Level :
OrderLineItem
table- PrimaryKey -
OrderLineItemHeaderID
- PrimaryKey -
OrderLineItemSequence
- PrimaryKey -
The problem is it doesn't let me make the foreign key between the second and third levels (OrderlineItemHeader.OrderLineItemHeaderID
to OrderLineItem.OrderLineItemHeaderId
). I've been reading about the hierarchyid data type but the problem is that they relate them on the same table. What I'm showing are the main columns, but each table has five to ten columns more of information needed.
I am using SQL Server 2008 and the program that will associate it will be VB.NET 4. I cant add an image of my diagram because I'm new to the website.
Going to Put the Explanation again With the Food Example:
You place a huge Order for a Food Providor who owns all the Restaraunts in the US.
The Order placed has general info for that one huge order list.
OrderID, OrderNO , OrderDate
Now that Order has Many different type of foods, which is the second level.
Pizza , Chicken, Meat, Fish .
You order 1000 of each and you need to know what is coming when.
So they give you that information and you need to show everyone is going to eat when they are going to eat.
So from Pizza youll have 100 coming on tuesday by air. 500 coming by water coming next week. and the rest by land in 2 weeks.
Meat has 500 coming tmorrow, but since they dont have more ready, its backordered for a future date the rest.
So all that info needs to be put in tablkes, hence the 3 tier model