Mysql 如何在配方表中添加自参考以允许子配方?

Mysql 如何在配方表中添加自参考以允许子配方?,mysql,sql,database,Mysql,Sql,Database,我想要一个包含配料列表和子配方列表的表格,例如: #recipe yellow lemon juice Ingredient unit cost quantity 1.Yellow lemon Kg 1.7 1 2.--suppose it has ingredient 2 3.--suppose it has ingredient 3 #recipe mayonnaise Ingredient unit cost qu

我想要一个包含配料列表和子配方列表的表格,例如:

#recipe yellow lemon juice
Ingredient         unit cost  quantity
1.Yellow lemon       Kg    1.7  1
2.--suppose it has ingredient 2
3.--suppose it has ingredient 3

#recipe mayonnaise
Ingredient                  unit cost  quantity
1.olive oil                 Lt  $2.5    1   
2.egg                       Kg  $2.5    0.12    
3.mustard                   Kg  $1.59   0.01    
4.salt                      Kg  $.9     0.01    
5.RECIPE yellow lemon juice Lt  $1.9   1 ------------this one is a recipe 
我怎么知道蛋黄酱配方使用的是黄色柠檬汁配方? 我有以下内容,但不知道如何在配方表中允许子配方

现在可能是这样的,我有3个食谱
A、B、C
,食谱
A
有几种成分,但也包括食谱
B
C


我可能会补充一点:

   Create table dressing
(
    dressing_id int, 
    recipe_id int,
    constraint pk_dressing primary key (dressing_id, recipe_id),
    constraint fk_recipe foreign key (recipe_id) references recipe(recipe_id),
    constraint fk_dressing foreign key (dressing_id) references recipe(recipe_id)
); 

我还想在蛋黄酱里加些糖和醋……:)

让我们假设调味品将是主桌,他们的一排将被食谱填充,所以在这种情况下,我会有两排柠檬汁食谱和有毒蛋黄酱,对吗?一点也不。您可以像往常一样在配方表中填写配方。但是,当一个食谱需要另一个食谱时,你可以用蛋黄酱食谱(必须在食谱表中)填满调味品表。食谱和SQL是令人困惑的lol
   Create table dressing
(
    dressing_id int, 
    recipe_id int,
    constraint pk_dressing primary key (dressing_id, recipe_id),
    constraint fk_recipe foreign key (recipe_id) references recipe(recipe_id),
    constraint fk_dressing foreign key (dressing_id) references recipe(recipe_id)
);