Jump to content

Need through relationship


pctechtv

This topic is 2997 days old. Please don't post here. Open a new topic instead.

Recommended Posts

While creating a database that has Products, Suppliers and Lines I have come across the need to calculate a count of the suppliers from the context of a Products record. My relationship is like so:

quickRel01.png.ac5c76936fb3a15dcb4f79879

My question if I want to pull a lot of information about Supplier is should my portal in the Products record be from Suppliers or from Lines? If the best answer is Lines, could I still have a count of related Suppliers by using the primary key from that table in the portal? Is it a bad idea to use fields from a related tables portal other than its own? Thanks

Link to comment
Share on other sites

  • 4 weeks later...

If you have a field in Products which is a count of suppliers, this will use your relationship and is completely unrelated to the decision on how to setup your portal.

If you want to know how many unique suppliers a product has, then I would use a calculation in Products that is a count on PK_Suppliers using your relationship. Depending on your setup, it may be sufficient to count FK_Suppliers from the Lines, but this would double-count suppliers that appear on more than one line (if this is possible in your system). It would also count Lines that have an invalid value in FK_Suppliers (a value that does not correspond to a Supplier).

As for the portal, if you only want to display information from Suppliers, then the portal should be to Suppliers (although it doesn't really matter in most cases), but if there is ANY information that you want to display from Lines, then the portal should be from lines. It is no problem to "extend" the relationship with a field from Suppliers in the portal to Lines, but you will have problems if you set up the portal to suppliers and then decide you want to stop half way to get some fields from lines - you'll end up with a line for each supplier but the additional data pulled from Lines will just be a repeat of the first matching Line record on every line of the portal.

Link to comment
Share on other sites

This topic is 2997 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.