|
Referential constraints are a powerful tool. But I'd have to have more information to go further. For example if I have Custmast table custnbr ... Itemmast table itemnbr ... CustPart table custnbr itemnbr custItemNbr // we say potatoe the customer says potato ... I would put two constraints on CustPart. No brainer. ADDPFCST FILE(CUSTPART) TYPE(*REFCST) KEY(CUSTNBR) PRNFILE(CUSTMAST) ADDPFCST FILE(CUSTPART) TYPE(*REFCST) KEY(ITEMNBR) PRNFILE(ITEMMAST) But how does one put a constraint to check that if we create a new item number, or a new customer number, to make sure that we have a customer item number to our item number part cross reference record? A possible solution is to put a constraint on the order detail file. orderDet table orderNbr LineNbr custNbr ItemNbr ... ADDPFCST FILE(ORDERDET) TYPE(*REFCST) KEY(CUSTNBR ITEMNBR) PRNFILE(CUSTPART) One minor quibble is how do we handle the rule that if there is no record in CustPart then just use our item#? Or do we not, just as a safety precaution? This might be a good point for a trigger instead of a constraint. At least on the ORDERDET file. Trigger that if they write a new record to the orderdet, and there is no matching CustPart then send an email to the inventory control specialist. Rob Berendt
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.