Best way to retrieve data from sub tables?

I have some parent child tables like so:

Bundle
-> Product
->Part
->PartCost

The product consists of multiple parts, parts have a “cost history”

I need to know the of the parts at the product level, then a sum of the products at the bundle level

Whats the easiest way to do this? I really wish I could write raw SQL, I could write that in my sleep :frowning:
Thanks!
Mikel

Hi @mikel

A table in bubblish is a “thing” and relating them is a matter of choosing a second thing (or list of second things) as part of one of the thing’s fields. This is the equivalent of setting up the primary key.

Once you built the “schema” … or in bubblish … all the things with their respective fields (texts, dates, or … related things) in the data tab. You can look them up within the elements or flows via building expressions such as "thing1’thing2’name (you just accesed the second thing’s name text field).

Hope this makes sense :+1:

It does, yes. This did help, however I have maths all over the place. IE:

I have 2 problems:

Sum(Cost * QTY) / Yield - You helped me fix this one.

Sum(Sum(Cost * QTY) / Yield)*QTY

My specific tables are as such:

Ingredient cost (Cost is here)
Ingredient
Recipe (Has Ingredient QTY “inner QTY”)
Candy (Has single Recipe, this is where yield is)
Product detail (Has multiple candies with outer QTY)
Product (Here is where I need the total cost)

I know how much a single candy costs, based on ingredient cost, ingredient qty, and batch yield.

I want to dynamically be able to see how much a product costs, when X amount of candy 1 and X amount of candy 2 are in that product.

Which would look like sum((candy 1 cost * candy 1 qty),(candy 2 cost * candy 2 qty),(candy 3 cost * candy 3 qty))

I just can’t wrap my head around that last part where each candy cost is Sum(Cost * QTY) / Yield.

I want to keep it dynamic, so when the price of an ingredient changes, we can update it and the cost of the candy/product adjust accordingly.

I can understand.

In Bubble you would have to build logic to achieve what you want.

Completely doable.