Simple look-up

Hi,

I’m new to Glide and I am not being able to find a solution for an apparently straightforward problem. I know that something similar has been discussed already multiple times, but coudn’t find yet the right solution.

I am writing a cookbook app. In a table, I need to add a column that is automatically drawn from another table, via a common ID. The first table (“Main”), among others, has an “Ingredient” column, and the second table (“Ingredients”) has two columns only: a corresponding “Ingredient” column and a second column (“Type”), which is the one I want to retrieve. The values for “Ingredient” in the “Ingredients” table are unique.

I have experience with SQL, so I understand the logic of tables and RDBMs. I assume that Glide automatically can build a relation between these two tables on the “Ingredient” key. If not, than mu problem is clearly that I haven’t built the proper relation …

However, assuming that the relation is indeed automatic, I have tried Lookup, Relation and Query, and none of these work. Best case, I can get all the possible types in the same cell.

Here some screenshots to better expain my problem:

With a Lookup:

With a relation (the link works, but how can I select the “Type” field from “Ingredients”?:

With a query (again, the query works but I cannot select another field):

For further clarity, this is the screenshot of the Main table. Here, I need to add the “type” column. For example, in the first row where “Ingredient” is “Riso” (Rice), the corresponding type should be “Solid”, In the fourth row (Latte = Milk) it should be “Liquid”

I hope I’ve been able to explain my problem clearly, any help will be very much appreciated
Thanks,
Bob

1 Like

You are on the right track with your Relation column, but your Lookup column is misconfigured.
Instead of targeting the entire Ingredients table, it should target the relation column in your Main table.

Thanks, I think I found a solution, which is probably what you are suggesting me, but let me ask you if I’m right. Basically I have created a “Relation column” (what I probably was missing) and then a lookup based on this value.

The new Main table now looks like this:

I find it a bit cumbersome … is it the right approach? My “Ingredient_rel” column looks like a duplication of the “Ingredient” column … is it really necessary?

Thanks

Yeah, it is a bit cumbersome, but that is the way that Glide works.
The relation column establishes a link from each row in your Main table to a matching row in your Ingredients table, and then if you need any values from the Ingredients table, you need to fetch them via Lookup columns.

What I think you’re expecting is something that we refer to as “Inline Lookups”. It’s something we’ve been requesting for a very long time, but it’s yet to materialise.

2 Likes