Skip to content Skip to sidebar Skip to footer

Creating A Table Inside A Table In Sqlite 3 (python)

I'm trying to create a sqlite database for a recipe storing program, that holds in the recipe table, the number of people, ingredients, cooking temperature and cooking time. I inte

Solution 1:

Use two tables, one for recipes, and one for ingredients, and have for each ingredient record the ID of the recipe it belongs to:

CREATETABLE recipe(ID, People, CookingTime);
CREATETABLE ingredient(ID, RecipeID, MassNumber, MassType, FoodType);

To add one ingredient to a recipe, just insert one record into that table (here, 42 is the ID of the recipe):

INSERTINTO ingredient(RecipeID, MassNumber, MassType, FoodType) VALUES (42, ...)

Post a Comment for "Creating A Table Inside A Table In Sqlite 3 (python)"