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.
Who is Participating?
jvaldesConnect With a Mentor Commented:
In the InvoiceLineItems Table, create a global fields for $CuntomerNo and $PartsCategory that are a calculated un-stored field, then create a dual relationship to the Parts discount table from the LineItems table. And that should work
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

sstiltonAuthor Commented:
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.
sstiltonAuthor Commented:
The last post was for TomDWallace I did not see comments from jvaldes.
sstiltonAuthor Commented:
Genuis!  Worked great! Thank you!
All Courses

From novice to tech pro — start learning today.