Forum Academy Marketplace Showcase Pricing Features

Database Logic for Simple Recipes

Hello,

I’ve been working on a basic recipe style feature for my app. While I have found a clunky workaround, I feel there is a better use of fields that reference other data types that I’m not taking advantage of.

Data Type & (relevant fields):

  • Recipe
    (List of Ingredients - Ingredients)
  • Ingredient

I have a field under Recipe for List of Ingredients. This of course helps me to add/ remove Ingredients to/from a Recipe. My trouble occurs when I want to record the quantity of an Ingredient in any particular Recipe. I don’t want to change a quantity field in the Ingredient because it changes from one Recipe to another.

To get around this I have created an additional data type:

  • Used Ingredients
    (Recipe - Recipe)
    (Ingredient - Ingredient)
    (Qty - Number)

Now, every time I add an Ingredient to my Recipe I create a new Used Ingredient to hold the recipe specific information of that Ingredient.

This will leave me the creation of a lot of redundant things, whose only differentiator is the quantity for a specific recipe. I would love to have the quantity information be stored in a field for Recipe but I cannot think of a way to do that.

Any help is much appreciated.

This should help

1 Like

Thank you, @boston85719,

Your link to Vertabelo, has really helped my thinking about databases. It led me down the path of learning what database normalization is.

Regarding my initial question, I think the concept of database normalization has helped me to understand that what I considered a clunky connection is really just a join table.

Anyone else interested in my question might find this specific link helpful:

1 Like

Hey all. It’s exactly what I need for my cookbook and I understand the article of DEV Community. But I don’t understand how to create entries in my Bubble database “Used Ingredients” related to a recepe. Is there any vids or lessons about that? Every recipe has a multiline ingredients list, every line contains a number (qty), a measure unit (from database “units”) and an ingredient (from database “ingredients”).