Design a Grocery Shopping List Database in Microsoft Access
Question details
Design a grocery shopping list database that relates menus, recipes, and ingredients without repeated fields.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A user wants to select a menu and generate a shopping list from the ingredients required by its recipes.
- Observed behavior
- The desired database stores menus, recipes, and ingredients separately and combines their quantities in a shopping-list query.
Decide how you will identify menus, recipes, and ingredients, and choose consistent units for ingredient quantities. The example assumes that each recipe appears only once per menu and that recipe quantities do not need to be scaled.
Create Related Tables and a Shopping-List Query in Access
Use junction tables to connect menus to recipes and recipes to ingredients, then total quantities for a selected menu.
In Access, select Create > Table Design. Create tblMenu with MenuID as an AutoNumber primary key and MenuName as Short Text. Create tblRecipe with RecipeID as an AutoNumber primary key and RecipeName as Short Text. Create tblIngredients with IngredientID as an AutoNumber primary key and IngredientName as Short Text.
Use Create > Table Design to create tblMenuRecipe with MenuID and RecipeID as Number fields with the Long Integer field size. Select both fields and click Primary Key to make a composite key. Create tblRecipeIngredient with RecipeID and IngredientID as Long Integer fields, Quantity as a Number field, and Unit as Short Text; make RecipeID and IngredientID its composite primary key.
Open Database Tools > Relationships and add all five tables. Drag tblMenu.MenuID to tblMenuRecipe.MenuID, tblRecipe.RecipeID to tblMenuRecipe.RecipeID and tblRecipeIngredient.RecipeID, and tblIngredients.IngredientID to tblRecipeIngredient.IngredientID. Select Enforce Referential Integrity for each relationship and click Create.
Open each table in Datasheet View. Enter menus, recipes, and ingredients in their main tables, then add matching IDs to tblMenuRecipe and tblRecipeIngredient. Enter the quantity and unit needed for each recipe ingredient.
Select Create > Query Design, switch to SQL View, and enter: PARAMETERS [Enter Menu ID] Long; SELECT I.IngredientID, I.IngredientName, RI.Unit, Sum(RI.Quantity) AS TotalQuantity FROM (tblMenuRecipe AS MR INNER JOIN tblRecipeIngredient AS RI ON MR.RecipeID = RI.RecipeID) INNER JOIN tblIngredients AS I ON RI.IngredientID = I.IngredientID WHERE MR.MenuID = [Enter Menu ID] GROUP BY I.IngredientID, I.IngredientName, RI.Unit; Run the query and enter the desired MenuID.

Organize Grocery Lists in WPS Spreadsheets
WPS Office is a free, lightweight, easy-to-use Office alternative with a familiar interface. Use WPS Spreadsheets to organize grocery lists and move existing Microsoft Office spreadsheet files into your workflow. It does not replace Microsoft Access database relationships or queries.

Frequently Asked Questions
Why do I need junction tables for a grocery database?
A menu can contain many recipes, and a recipe can belong to many menus. Likewise, recipes and ingredients have a many-to-many relationship. Junction tables store those links without adding repeated recipe or ingredient fields.
Where should I store the quantity of an ingredient?
Store Quantity and Unit in tblRecipeIngredient because the amount of an ingredient can differ by recipe. Enter those values alongside the RecipeID and IngredientID in Datasheet View.
Will the shopping-list query combine cups and ounces automatically?
No. The example groups by ingredient and unit, so cups and ounces appear separately. Use consistent units when entering data or build a separate conversion method before totaling them.
Can I add the same recipe more than once to a menu?
Not with MenuID and RecipeID as the composite primary key. To support repeated servings or batches, add a scaling field to tblMenuRecipe and update the query to multiply ingredient quantities by that value.




