If this feature has not been designed in from the beginning of the project, then you ought to be able to tack on meta-data derived from tables containing the relationships.
id - category
1 | Desserts
2 | Starters
id - main_ref - category
1 | 1 | Puddings
2 | 1 | Cakes
3 | 2 | Sea food
id - sub_ref - item
1 | 1 | Sticky Toffee Pudding
2 | 2 | Banana Cake
3 | 3 | Prawn Cocktail
You can do similar with single table using natural keys
main - sub - item
Desserts - Puddings - Sticky Toffee Pudding
Desserts - Puddings - Jam Rolly Polly
Where you then make sure that all 3 fields enforce uniqueness, and then index the "item" for faster lookups - but you will be matching text to text - so will have to take that into consideration when say, renaming an item.
You could just use and id number of course.
All this will depend on how easily you introduce this to your cms backend - of course.