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

  • SEARCH
  • Home
  • 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 9192457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:55:44+00:00 2026-06-17T20:55:44+00:00

I have taken on the project of creating a relation database which will contains

  • 0

I have taken on the project of creating a relation database which will contains all the basic ingredients we use in modern cooking. As you could imagine, there are going to be thousands of items. I do not have much sql experience so I am having trouble arriving at a seemingly efficient way of storing the ingredients.
If you go here http://en.wikipedia.org/wiki/Outline_of_food_preparation#General_ingredients you can see the list I am currently trying to put into my database.

My database current has a table for every main and sub category of food ex. a table for cereals and a different table for wheat. At first it seemed okay to do this, but then i realized that there are going to be dozens more sub categories. For each item in that wiki list there are more tables and more tables that I must create. I feel like this plethora of tables will make my project very inefficient. Is there a better way to create my database? Or am I on the right track? Here is an example of the columns in my tables:

    id INT(11),name VARCHAR(45),parent INT(11),img VARCHAR(45),desc VARCHAR(45)

parent INT(11) will be a foreign key to whatever the parent table is, so I figured they will all connect this way.
Any advice is appreciated! ~THANKS

  • 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-17T20:55:45+00:00Added an answer on June 17, 2026 at 8:55 pm

    I would first not recommend storing all these in separate tables — it’ll drive you crazy 🙂

    Instead however, I think you have 2 options.

    Option 1 (Adjacency List Model) — Consider using a single Foods table, with FoodId, FoodName, ParentFoodId, AnyOtherAttributes you wish to store. This is easiest to store the data, but can be a little more troublesome to return your results as you’ll need to join on the same table multiple times to return levels.

    Option 2 (Nested Set Model) — This option still would have the single Foods table, but instead of having a ParentFoodId, you’ld have 2 columns, left_index and right_index. This is perhaps a little more complicated to understand at first, but can be easier to query if you have several unknown nested parent-to-child relationships.

    Take a look at this article for some further explanations:

    http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/

    Good luck.

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

Sidebar

Related Questions

I have recently taken on a project in which I need to integrate with
In my project I have a model which holds basic information about model. For
I have taken the org.eclipse.equinox.p2.examples.rcp.prestartupdate project and adapted it for use in my RCP
I have taken over a project that was build from suggestions in this Dan
I have taken over an existing project written beautifully in SQL with many useful
I have been working on an iPhone project, where we created all the user
I have a large project which was originally written in C#1.1 and is now
I have inherited a project from my predecessor which uses OpenRasta to host a
I want to use Global variale in my project so I have simply take
I need to use a SoapExtension subclass (which I have created), but it seems

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.