I look at it this way; your root item is your "Menu Item", and everything else is basically a "variation" of the menu item; from sizes, to add-ons, to options.
I think there's scope to simplify this schema by doing the following:
- Remove "Menu Item Variants (for portion sizes)" table
- Remove "Menu Item Options" table
- Remove "Menu Items Add-Ons" table
- Consolidate all of the above into variation groups, with variation group items
For example:
Item Variation Groups Table:
These would represent logical groupings of variations; sizes, noodle optons, addons etc. - basically anything you can think of.
If you think about it from the UI point of view, it represents each dropdown, or list of items, you may use to customise your menu item.
Using something like min_selection
and max_selection
, you can make a selection in the group optional (0 min), mandatory (1 min), or upto X selectable options.
id (PK) |
account_id |
name |
description |
min_selection |
max_selection |
1 |
1 |
Sooup noodle options |
Options for your noodles |
0 |
1 |
2 |
1 |
Soup Addons |
Popular addons for our soups |
0 |
2 |
3 |
1 |
Soup sizes |
Sizes for our soups |
1 |
1 |
Variation Group Items Table:
Here, you define the specific items that belong to your groups.
id (PK) |
variation_group |
name |
description |
price_adjustment |
1 |
1 |
No noodles |
|
-1.00 |
2 |
1 |
Sub gluten free noodles |
|
3.00 |
3 |
2 |
Wonton |
Spicy wonton |
3.00 |
4 |
2 |
Meatballs |
Spicy meatball |
4.00 |
4 |
3 |
Standard |
10 oz |
0.00 |
5 |
3 |
Large |
12 oz |
3.00 |
6 |
3 |
X-Large |
15 oz |
5.00 |
Menu Item Variation Groups Table:
And here, you assign groups to each menu item. The benefit of this approach is, if you have 10 soups on your menu, you can re-assign the same groups - no need to duplicate data.
If you need a variation for a particular item, you can introduce a new group, with some new items.
id (PK) |
menu_item_id |
variation_group_id |
1 |
1 |
1 |
2 |
1 |
2 |
2 |
1 |
3 |
Benefits
- You reduce the complexity of your schema, but increase flexibility
- Groups can be re-used across similar menu items
This is, of course, just a suggestion - it may even jog your brain and help you think of an alternative.
Good luck!