Forum Academy Marketplace Showcase Pricing Features

Best approach for handling paired values + help on displaying list of things in RG

Hi there,

I saw similar posts on the subject but somehow cannot work it out.

I am creating product made of different ingredients / quantities e.g the “English Breakfast” product would be made of Bacon x3 and Eggs x2 (I know; frugal :))
I also need to be able to keep track of the quantity left for each ingredient (so that I can re-order if needed) so the inventory side of the app is quite important as well.

Q1
What is the best way to store those values? At the moment, I went where 2 list of things (one for ingredient and the other one for quantity. So in practice I have ingredient = egg, bacon and then quantity = 2 , 3 stored in my database.
Is it the best way to do it?

Q2
I went ahead with the 2 list of things.
I created a repeating group so I can see the ingredient / quantity added to make the product. For some reason there is no data populated after row 1. Any idea on why this does not work?

This is the RG in the editor

This is the database structure


image

And the RG in preview
image

You can, but it’s inevitably going to get tricky (e.g. when you want to change the sort order in your repeating group).

I’d rather set it up with two days types:

  1. “Ingredient” with fields
  • name (e.g. egg)
  • inventory (number remaining)
  • reorder threshold
  • etc
  1. “Component” which has fields:
  • Ingredient (i.e. per above),
  • quantity required,
  • recipe (e.g. English breakfast)

When you search for “English breakfast” in the Components table you’ll get a list of required ingredients and can access their quantities.

When a dish is ordered, you run a backend workflow to loop through each Components Ingredient and reduce the inventory by the Component quantity.

Rob

Hi @robhblake ,

Thank you so much for that. I understand your approach.

My main issue is that my recipe (English Breakfast) has a lot more attributes that just ingredient and quantity. If I follow your logic that means I will have to create another data type for “recipe” as well right?
Just my pure (non-tech) instinct here, I would prefer having all product related info in the same data type rather than broken down in 3.

So this is what I had in mind (before implementing it on Bubble). All recipe (aka finished goods), intermediary products (which are specific ingredients to the recipe) and ingredient (aka raw material) in the same table. Then whenever an “English breakfast” is ordered then create a workflow going through each item of the ingredient list and update inventory count accordingly.

Is it even feasible in Bubble or do I have to go the 3 data types route?
Aside from the sorting issue you mentioned in the repeating group (which I do not think is an issue for me), is there other aspects which would be very difficult to do with one table?

Thank you so much for the support!
Tom