Link to home
Start Free TrialLog in
Avatar of sstilton
sstilton

asked on

Database Relationship Help

Developing Invoicing and Inventory management database with FM Pro 11.  Tables are Customers, Invoices, LineItems, Part Categories, Parts, Customer Discounts.  Customer Discounts are related to Customers with Customer No as the FK.  Invoices are related to Customers with the Customer No. as the FK. Line Items are related to Invoices with the Invoice No. as the FK.  Parts are related to Part Categories with the Category as the FK.  The problem is with the Customer Discounts, which fields are Customer No., Parts Category, and Discount Amt.  Everything works fine except the I cannot figure out the relationship structure that allows the customer discount to be applied based on the Part Category and the Customer No. in the line items table for each line item.  Any help would be GREATLY appreciated! Screenshot of relationship diagram included.
tables.bmp
Avatar of gangsta1766
gangsta1766

aushiu suhaud ashsauda
I assume you are going to have a calculation field in the 'InvoiceLineItems' table that calculates the sub total based on the Discount & Qty Sold ?

If so, add an instance of 'CustomerDiscount' onto 'Parts' related by 'PartCategory'

Make a calculation in the context of 'LineItems'  There could be a separate calculation field called 'Discount' in LineItems or you could do it all in the SubTotal calculation

There will be a discount if LineItems_Parts_CustomerDiscount::CustomerNo = Customers::CustomerNo

ASKER CERTIFIED SOLUTION
Avatar of jvaldes
jvaldes
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sstilton

ASKER

Still not working.  It will get the correct category, but then it applies the discount of the first customer record with that category.  Each customer may have a different discount rate for the same category.  For example customer1 may have a discount rate of 10% for category1 and customer2 may have a discount rate of 15% for category1.  This is the trouble I have had.  I can get either the correct category or the correct discount, but I haven't been able to get the correct category and discount for the each customer.
The last post was for TomDWallace I did not see comments from jvaldes.
Genuis!  Worked great! Thank you!