I am in the process of structuring a SQL database for a recipe website that I am playing around with. I am new to the many-to-many style and am not confident in what I have so far. Inevitably, what I would like the end result to do is to have a solid set up where users can:
Add a recipe to the database
Sort by prep-time, cook-time, cuisine, category, food category and course
Ability to generate a shopping list from a weekly meal plan by adding the total amount of ingredients from the recipes selected. (This is the most important!)
I will challenge myself to work out how to add the ingredients from the recipes to generate a shopping list, but the question for this post is "How should I structure my tables and connect everything?"
This is what I have so far in my SQL database:
If you think you have the answer please structure your tables similar to mine. I am a visual learner and it would be much appreciated. Also, if you could explain what I may or may not be missing would be greatly appreciated.
- Recipe(table)
- recipe_id (primary key)
- recipe_name
- recipe_description
- course
- food_category
- cuisine
- prep_time
- cook_time
- Ingredients(table)
- ingredient_id (primary key)
- ingredient_name
- recipe_id (foreign key)
- Quantity(table)
- quantity_id (primary key)
- recipe_id (foreign key)
- ingredient_id (foreign key)
- ingredient_quantity
- ingredient_measurement
- Recipe Steps(table)
- step_id (primary key)
- step_description
- recipe_id (foreign key)
- Join(table)*
- join_id (primary key)
- recipes_id(foreign key)
- ingredients_id(foreign key)
- quantity
// I do not know if I need this 'join' table since 'quantity' seems to be similar
Thank you in advance!