I am trying to design a restaurant ordering system in UML, which should also include the stock system.
One of the classes is a Dish
(i.e. a dish on the menu), and another is an Ingredient
.
My initial idea was to place an aggregation of Ingredient
s within Dish
, but I’ve also read that a many to many relationship is more appropriate.
My problem is that in this case, simply having a relationship isn’t enough. For instance a Dish
could have 30g of Ingredient
A, while another Dish
could have 20g of Ingredient
A.
How can I model this kind of dependency in UML?
1
Create a Many to Many relationship; call it DishIngredients
.
Include Amount
and Units
fields in DishIngredients
; this will let you specify the amount (e.g. 30) and units (e.g. grams) for each Dish/Ingredient combination.
An Ingredient is a Product in a Recipe (or Dish) with it’s Quantity (quantity should include Unit of Measure and be translatable between units). A Recipe contains many Ingredients. A Product can be in many Ingredients. And can be in Stock with a Quantity as well.