Restaurants have buffets. and Buffets have different spreads. i wanna enable photo and comments on each dish on the Buffet. not sure which is the best way to store them in Database
What i have done ?
I have a Restaurant Db that stores the general information of the REst.
Dishes DB that stores Dishes of the Resturants. each dish is again mapped to a category like Starters, Drinks, Main Course.
Now how to store the Dishes as a part of a Buffet of a Restaurant in a normalized way.
You need a Restaurant table with a unique primary key REST_ID and other Restaurant attributes (like name and location, name of chef)
You need a Buffet table with the primary key (REST_ID, BUFFET_ID), and other Buffet attributes such as name ( “Salad Bar,” “Smorgasbord,” or “Sweets” for example.)
You need a Dish table with the primary key (REST_ID, BUFFET_ID, DISH_ID) and other attributes such as name (“Potato Salad,” “Buttered Nan”)
You need a Photos table with the primary key (REST_ID, BUFFET_ID, DISH_ID, PHOTO_ID) and other attributes, for example a pathname or blob for the photo itself, and a caption.
You need a Reviews table with the primary key (REST_ID, BUFFET_ID, DISH_ID, REVIEW_ID).
Notice that there’s a design choice in this data model: it is not possible for the same dish to appear on two different buffets. Nor is it possible for the same buffet to appear in two different restaurants. That is, the data is strictly hierarchical:
This makes sense for a review application. If you get food poisoning from the egg salad in Restaurant A, it makes no sense for your negative review of the dish to appear under Restaurant B.
Here are some example rows for each table.
Restaurant (REST_ID, Name, Chef)
Buffet (REST_ID, BUFFET_ID, Name)
Dish: (REST_ID, BUFFET_ID, DISH_ID, name and category)
etc.