我通常有一个单一的食谱表,因此很容易将其插入数据库中,如下所示:
INSERT INTO Recipes(Version, Owner, Title, Categories, Serves, Source,
Ingredients, Instructions, PictureName, LastUpdate,
Favourite, Deleted)
VALUES('" + Version$ + "','" + Owner$ + "','" + Title$ + "','" +
Categories$ + "','" + Serve$ + "','" + Source$ + "','" +
Ingredient$ + "','" + InStruction$ + "','" + PictureName$ +
"','" + LaStUpdate + "','" + Favourite$ + "','" + "0"
但是,我希望“正常化”我的数据库,如下所示,以便更灵活,节省空间,冗余等。我将从头开始使用相同的表格来收集数据(成分,说明)和类别是列表)但我不知道如何进行复杂/复合插入查询以处理链接表等的所有关系。
有人能指出我正确的方向吗?我是这种“正常化”战略的新手。
recipes table recipe_id recipe_name recipe_version recipe_owner recipe_author recipe_source recipe_copyright recipe_lastupdate recipe_favourite recipe_deleted recipe_description recipe_notes recipe_servings recipe_peparationtime recipe_cookingtime recipe_totaltime ingredients table ingredient_id ingredient_name ingredient_price recipe_ingredients table recipe_id ingredient_id ingredient_amount recipe_instructions table recipe_id recipe_step step_description category table category_id category_name recipe_category table recipe_id category_id picture table picture_id picture_name picture_url recipe_pictures table recipe_id picture_id