954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Quantity Contract and Purchase Order dilemma

I am a newbie looking at designing a simple database for my manufacture-based company, part of the job it does is maintaining a Purchase Order Table, a typical one and it suits all the customers we have, except for 1 particular customer which typically issues a Quantity Contract - a contractual agreement to purchase a number of specific Product with a specific Qty, this contract would eventually be superceded(materialized) by a single OR a sequence of Purchase Orders, without which a delivery cannot be performed.

I'm stuck at the design of the tblPurchaseOrder and tblQuantityContract, and it's relationship.

Seek a kind soul for enlightenment. Thanks.

SNES
Newbie Poster
2 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

Part of the problem (as I understand it, and sorry if I misinterpreted) is that the Quantity Contract is related to the Customer first. Therefore, if you want referential integrity between tblPurchaseOrder and tblQuantityContract, you have to either have a nullable foreign key into tblPurchaseOrder from tblQuantityContract, or you have to have a child table to resolve between tblPurchaseOrder and tblQuantityContract.

If you have the nullable foreign key, then each PurchaseOrder can be related to only one QuantityContract. That automatically limits the PurchaseOrder to a single product at a time (not very flexible). If you go further and have the foreign key to the PurchaseOrderLineItem (assuming you have one) that gives you a better fit but you have to programmatically ensure how much of the QuantityContract is satisfied by a specific PurchaseOrderLineItem. Still not ideal.

I suggest you go with a child table to resolve between PurchaseOrderLineItem and QuantityContract. QuantityContract has a non-identifying relationship to Customer. It doesn't require you to maintain a column in the PurchaseOrder (or -LineItem) for Customers that don't use QuantityContracts, and lets you test for existence rather than have to do a bunch of null-testing for every PurchaseOrder.

Hope this helps some! Good luck!

BitBlt
Master Poster
711 posts since Feb 2011
Reputation Points: 367
Solved Threads: 109
 

Can a purchase order have more than one product on it.

if not, put a foreign key (ContractId) in the tblPurchaseOrder table.
if so, put a foreign key (ContractId) in the tblPurchaseOrderLine table.

ChrisPadgham
Posting Pro in Training
413 posts since Sep 2009
Reputation Points: 102
Solved Threads: 78
 

thank you both for your inputs, let me spend a bit of time on this.

SNES
Newbie Poster
2 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You