Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8953741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:09:58+00:00 2026-06-15T14:09:58+00:00

I have an food ordering system that has main item such as latte, long

  • 0

I have an food ordering system that has main item such as latte, long black, flat white, espresso, americano etc. Each item is stored in a DB as follows.

*db missing unnecessary columns

  +----+----------------+-------------+
  | id | item_name      | price       |
  +----+----------------+-------------+
  | 1  | latte          | 2.0000      |
  +----+----------------+-------------+
  | 2  | long black     | 2.5000      |
  +----+----------------+-------------+
  | 3  | flat white     | 3.0000      |
  +----+----------------+-------------+
  | 4  | americano      | 2.0000      |
  +----+----------------+-------------+

I need to add sub-options to each item but each item will have unique set of options for example americano will have a milk type, sugar type. Flat white will have a milk type also but will need to be a different menu as americano may not require a milk option so will have a different submenu. For example.

   Flat white milk menu 
  +----+----------------+------------+
  | id | item_name      | submenu_id |
  +----+----------------+------------+
  | 1  | soy            |     1      |
  +----+----------------+------------+
  | 2  | rice           |     1      |
  +----+----------------+------------+
  | 3  | regular        |     1      |
  +----+----------------+------------+
  | 4  | trim           |     1      |
  +----+----------------+------------+

   americano milk menu 
  +----+----------------+------------+
  | id | item_name      | submenu_id |
  +----+----------------+------------+
  | 5  | soy            |     2      |
  +----+----------------+------------+
  | 6  | rice           |     2      |
  +----+----------------+------------+
  | 7  | regular        |     2      |
  +----+----------------+------------+
  | 8  | trim           |     2      |
  +----+----------------+------------+
  | 9  | no Milk        |     2      |
  +----+----------------+------------+

Then there may be a common item such as sugar…

         sugar
  +----+----------------+------------+
  | id | item_name      | submenu_id |
  +----+----------------+------------+
  | 10 | Sugar          |     3      |
  +----+----------------+------------+
  | 11 | no Sugar       |     3      |
  +----+----------------+------------+

What would be the best way to store the hierarchy in the DB? For example flat white would need the values 1,3 americano will need 2,3. The same kind of system may be required for something that requires many more options. I need to be able to pull these out and load each sub option with javascript.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:09:59+00:00Added an answer on June 15, 2026 at 2:09 pm

    Does each sub-option belong to one option only or two several options? I imagine that sugar would belong to each option….

    In which case, you will need three tables: an options table such as you already have (id/name/price), a sub-options table (id/name) and a join table (option/sub-option). You could probably combine the options and sub-options tables by adding a flag field, although in this case you would have to ensure that the join table is populated correctly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL database with has the following: Customer, Item, Clothing and Food.
I have an object that represents a food item to order at a restaurant.
I have 2 tables: FOOD and INGREDIENTS. I want to select all ingredients that
I have a function that shrinks the size of a Food bank (represented by
I have two tables in my database - Category and Food. Food has idCategory.
I have a page that displays restaurant food menu. And when a person clicks
I have an interface that has ~16 input field boxes. They are all declared
For a food online-ordering application, I have worked out how many ingridients we need
I have a food database and I'm trying to implement a simple search that
I have a query that outputs results as follows: Person Food ====== ====== Abner

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.