I'm making a simple recipe app that allows user to create and save their recipes. I'm using SQLite if that makes any difference.
My database knowledge is a bit rusty so I've been looking around for inspiration in order to design an appropriate database.
One example that users here seem to point to is the following schema by Barry Williams: http://ift.tt/1x3NjSD This db is overly detailed so I decided to used only the following tables:
Recipe (recipe_id(PK), name, description)
Ingredient (ingredient_id(PK), name)
Recipe_Steps (recipe_id(PF), step_number(PK), instructions)
Recipe_Step_Ingredients(recipe_id(PF), step_number(PF), ingredient_id(PF), amount)
From my understanding, each ingredient is associated to a step in the recipe whereas I feel like each ingredient should be associated directly to a recipe and that the steps could be an attribute of the recipe table or in a Step table directly related to Recipe. Here would be my design:
Recipe (recipe_id(PK), name, description)
Ingredient (ingredient_id(PK), name)
Recipe_Steps (recipe_id(PF), step_number(PK), instructions)
Recipe_Ingredients (recipe_id(PF), ingredient_id(PF), amount)
Mr. Williams knows much more about databases than I do so I don't know if I'm misunderstanding his schema and screwing it up with my version or if this all comes down to personal preference in design.
Is my version of the schema correct, if not, would you please be able to guide me towards the appropriate answer?
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire