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.