Bubble Noob - stuck for a week. Trying to achieve Join tables but unable to achieve it

Hi,

I am a complete noob in Bubble and I am trying to create a small internal use web app for my family business. I am currently stuck at the following step and in spite of exhaustive googling over the past 3-4 days I am unable to proceed any further. Will appreciate any insights.

We make handmade carpets. Every design has several colorways and each colorway will have different combinations of yarn in it and every yarn has a different percent of use in that particular design/colorway.

So For example in Design 123, Colorway A

Yarn Code 1 - 30%
Yarn Code 2 - 20%
Yarn Code 3 - 15%
Yarn Code 4 - 35%

Now I have a Data Type Yarn, a Data Type Design, a Data Type Colorway and a Data Type Colorway Line Item.

So to add a new design or colorway, I want to create a Repeating Group which will show all available Yarns, show an input box next to it to type in the percentage, and when save is clicked, I save the chosen yarns and their percentage into the related records for that particular design/colorway. Tutorials for saving this as a list of yarns are available but if I save it as a simple list of yarns then I don’t get to save the percentage along with it which is essential for my purpose.
So I need to save this under colorway line item and join the tables like in a conventional RDBMS but am lost at how to implement this.

Any tutorials/guides that you can point me towards will be very helpful.

Thanks,
Karan

You want to look at how shopping baskets work as that is kind of what you are trying to do.
You have 1 stock code (yarn) which can allocated to many Baskets (Colorways). You need to have a table in the middle a bit like an order or shopping basked that stores the yarn %.

In you repeating group, presumably you have a input field for the percentage.

When you store the yarn, are you just storing a list of yarns against a colorway, if so, a yarn will not have a % value as you only have 1 yarn record. What you need to do is have a Yarn_use data type that will be used to store the % against a colorway as a list of Yarn_uses. You will need to add a list of Yarn_use fields to your colorway.

Yarn_Use (or call it whatever you want)
Yarn (this will be the Yarn from your list of yarns)
Percentage (percentage from the input field of that yarn,

1 Like

Hi,
Thank you for your answer.

What you need to do is have a Yarn_use data type that will be used to store the % against a colorway as a list of Yarn_uses. You will need to add a list of Yarn_use fields to your colorway.

Ok, so this is exactly where I am confused. Youtube and Google showed me that the way to implement this would be to create custom states and add each desired yarn to the list of yarn_use on each colorway. But when exactly do I store the percent of each yarn under that particular colorway? (Sorry if that is confusing, English is not my primary language)

Do you mean to say I should write the yarn code and yarn percentage to the database in data type yarn_use and also add a list of yarn_use to the colorway?

I am on mobile right now, but I will add pictures of my data structure and a mockup of my desired result as soon as I am able to access my laptop. That will better explain what I am trying to say & achieve. I appreciate your insights, thank you so much.

The custom states are just a way of storing the % temporarily until it is save d to the database.

Yes you are effectively saving a yarn_use with the % and then adding this to the colourway record. Another way is to add every yarn to the colorway record, for instance if you only had Red Green and Blue Yarn, then this would make sense, but if you have 100’s and stock changes all the time then it would not.

Check out this forum post on the List Shifter plugin

Somewhere in there is an example by the developer (might be on a video) but I recall that he had at one point put together an example that was for House Paint Colors and doing something similar to what you are looking to do.

If you are really stuck I could go over with you how to setup a ‘Shopping Cart’ type of setup that will allow you to do what you want…the setup is too much to cover in a forum post, so you could book a private session and in an hour we could cover it and have you up and running.

Book a Session

1 Like

Hi @karan.ag ! How are you?

You almost got it and you are in the right path :wink:

You will need another table in your database called “yarn-colorway”. To store the percentage of each yarn in your new Colorway composition…

The structure of this table will be something like this:

  • Colorway (Type = Colorway)
  • Yarn (Type = Yarn)
  • Percentage (Type = number)

So imagine you have the situation below:

CREATE A NEW COLOR WAY:
Name: TestColor

COMPOSITION:

[ 30% ] Yarn Code 1
[ 30% ] Yarn Code 2
[ 20% ] Yarn Code 3
[ 20% ] Yarn Code 4
[ 0% ] Yarn Code 5

[SAVE]

So after you fill the inputs with the desired percentage you will need to create several entries in your yarn-colorway table to store and connect the yarn and it’s percentage to the new Colorway.

The entries will be:

TestColor | YarnCode 1 | 0.30
TestColor | YarnCode 2 | 0.30
TestColor | YarnCode 3 | 0.20
TestColor | YarnCode 4 | 0.20
TestColor | YarnCode 5 | 0

Now, to view the composition of the Colorway called “TestColor” you just need to run a Search For yarn-colorway where the Colorway = TestColor. You can use a repeating group to show the Yarn and it’s percentage.

Hope it helps!

1 Like

Hi,

Thank you for your reply. This is exactly how I want to do it but I am still scratching my head over how to implement this.

My main problem right now is, in data type Colorway Line Item, I have a field Colorway, so when I try to constrain the repeating group I cannot choose Colorway = TestColor as that is giving an error. I am assuming this is because Colorway is of datatype colorway whereas TestColor is simple text. (not sure if I explained my problem correctly)

This is a link to a stripped-down version of what I am trying to do, it has only the current problem and nothing else.

I know I am missing something extremely basic. Thank you for your help in advance

Hi @karan.ag !

You are right. The Colorway is a datatype in you database. ColorTest is just the name of one of them.

There are many ways to do what you desire. But one, that is very simple, is to use a “Search box” to let you search and choose the Colorway you want.

So you can link your constraint with the value of the Search Box. I am in a Uber right now, so can’t give you an example. But I am sure if you explore this component you will understand it’s behavior.

Let me know the result!

1 Like

Thank you for your input, I will try it out this evening and let you know if I succeed.

If not, hopefully, you will allow me to pick your head just a little more.

Thanks,
Karan