I am designing a SQL database to hold recipe/pricing information. So far, it looks like this:
The idea is to track prices of various ingredients (brand specific) along with their prices so that the total cost of a given recipe can be calculated and tracked over time.
The issue is that not all recipes require brand specific ingredients, but some do. For example, a recipe for one cake may simply call for half a cup of milk, while a recipe for a second cake may call for half a cup of Alta Dena brand milk.
My plan to address this was to create an intermediate table, called Ingredient, with Ingredient: Item as a one to many relationship. In this set up, a recipe would call for a half cup of milk (an Ingredient) and this Ingredient could be mapped to multiple Items, say Alta Dena milk, Horizon milk, etc, each with a separate price.
That set up would look like this (excuse the poor mock up but I wanted just to get a quick visual.) There would need to be a separate IngredientToItem table as well, so think of the Ingredient table as just a placeholder for everything here.
This almost fixes the initial issue that not all recipes call for a specific brand, but it introduces a new problem: some recipes do call for a brand specific ingredient (Item.)
I am wondering what I should do now. Is there a common structure for this type of problem? Should I have two separate tables RecipeIngredients and RecipeItems, one each referring to the brand agnostic ingredients and the brand specific items? Should I add a nullable column to the RecipeIngredients table to refer to a specific Item where necessary?