2013-03-13 62 views
0

我有兩個表Order_Primary和Order_Complete問題是當我想生成賬單時,Order_Primary表中的賬單中可能有多個產品,因此它會爲每個單一產品生成OrderId,儘管它們來自同一法案,現在我應該如何在Order_Complete表中的所有這些的OrderId相關聯的將有多個OrderIds同一產品,但必須有唯一的一個BillNoOrder Tables Schema Issue

Order_Primary

的OrderId(主鍵)
ProductId(外鍵)
個類別ID(外鍵)
數量
成本
僱員(外鍵)

Order_Complete

BillNo(主鍵)
的OrderId(外鍵)
日期

回答

-1

爲了讓你有你的數據結構的變化,以這樣的期望的結果:

PRODUCT_GROUP(添加新表格)

ProductId (Foreign Key) 
ProductGroupId 
ProductGroupId+ProductId (Primary Key) 

Order_Primary

OrderId (Primary Key) 
ProductGroupId 
^(Now here with a ProductGroupId you will get a list of products(Multiple)) 
CategoryId (Foreign Key) 
Quantity 
Cost 
EmployeeId (Foreign Key) 

Order_Complete

BillNo (Primary Key) 
OrderId (Foreign Key) 
Date