Linking Two Things between App data Tables

Hi Bubble Community,

I have two datasets, one named Products and one named Vendors. In Products, I have a field called Vendor which is a List of Vendors. In Vendors, I have a field called Products which is a List of Products. A vendor has many products and each product can have many vendors.

I have created a page for vendors to add products. Once the vendor inputs metadata into the input text box, they click a button to submit their new product triggering a workflow:

The current set up I have creates a new product, and a new vendor in their respective tables but doesn’t add the listed product to the Vendors table, nor the vendor name to the Product table.

Is there a way to add these two fields to their counterpart tables (ie: add the product to the Vendor table’s product field, and vice versa)? I would like to add the product to an existing vendor if the vendor already exists, or create a new vendor when the vendor does not exist. This was the closest existing thread to troubleshoot I found.

2 Likes

In step 3 do : make changes to product - add result of step 2 create a new vendor
step 4 : make changes to vendor - add result of step 1 create a new product.

And under both product and vendor data types you need to have them added to their counterpart tables.

Hi @aryan2003dikshit I added in steps 3 and 4 to create a new vendor and new product. However, when I added in the new sample product, the vendor still does not show. I would like to join the “This is a sample Vendor” to the Vendor field in the same row as the “This is a sample Product” and vice versa.



Could you expand on adding product and vendor to their counterpart tables?

For context, here is my Vendor dataset:


And here is my Product dataset:

could you show me both the workflows as well?

@aryan2003dikshit
Here is the workflow. Step 1:


Step 2:

Step 3: Make changes to Product was no problem.

Step 4: Make changes to Product since result of step 1 was to create a new product. There was not an option of Make changes to Vendor.

Step 5 just resets the page for the vendors to add in their product metadata.

Just as an alternative. Have you thought about adding a linking table instead. Each product-link would have a single product and a single vendor attached to it. This allows you to scale to an unlimited amount of product and vendor attachments. You won’t be limited to trying to have a list on data type. Does that make sense? Would something similar to that work for your situation? Is there any reason you can’t do it that way instead?

Let me know your thoughts. :blush:

@J805 That could work since the vendor-product relationship would be many-to-many. My main concern is linking these tables. How would I connect the individual product and vendor tables to the bridge table? In SQL, there would be two separate keys to join the individual tables to the linking table.

I’ve built the workflow so that if a customer clicks on a vendor, all the products that vendor offers is displayed. As long as I can link the individual product and vendor tables to the linking table, then this would likely work.

Yeah. If you save the vendor and the product on the data record then it would work just like how you said. :blush:

1 Like

@J805
Thanks for the idea. How would I actually link the vendor from the vendor table to the vendor in the bridge table, and the product from the product table to the product in the bridge table? Is Bubble smart enough to link them by knowing their names are the same?

2 Likes

Like this using another datatype :blush: vendor-products | Bubble Editor

1 Like

Great, thanks everyone for your help!

3 Likes

Glad that helped. :blush:

Hey @kpeksenar this is Nathan from lowcodehelpers. I sent you a DM.