Design tables of days and Time for restaurants


#1

I have a database that includes the names of the restaurants and the menus of restaurants and dishes in each restaurant.
Now I want to specify what every food is served in what days and when.
So I acted as follows. Is this the right way?

Restaurant
--------------------
Id
Name
Menu
----------------
Id
Name
RestId
Food
---------------
Id
Name
RestId
MenuId
Days
------------------
Id
Name
Time
----------------
Id
Name
MenuDayTime
---------------------------
MenuId
DayId
TimeId

tnx


#2

i would question the need for and/or design of the Days and Time tables – i think you can accomplish the requirement with simple columns

also, since a menu can belong to only one restaurant, the RestId column in the Food table is redundant

but what are you going to do if a food item (e.g. onions) can belong to multiple foods in different restaurants?


#3

Assume that each restaurant has several menus, for example, the breakfast menu dinner menu lunch menu. In this case, each menu will be released at a specific time.
Now, if the breakfast menu is served on Fridays, Saturdays, Sundays, Mondays, Tuesdays, Wednesdays, and Wednesdays, from 8 to 10 in the morning, and Sundays of 8.5 to 11, how can I do with a few simple design columns?


#4

For example, I want to find a meal and show the restaurant that serves it. Is this not necessary?


#5

For this, I acted as follows

Food

Id
Name

Stuff

Id
Name

FoodStuff

FoodId
StuffId


#6

Assume Breakffast Menu is ID 1.

MenuID Day TimeStart TimeEnd
1 0 8 10
1 1 8 10
1 2 8 10
1 3 8 10
1 4 8 10
1 5 8 10
1 6 8.5 11

(Alternatively, have a DayStart and DayEnd as well, which is the more likely scenario: a menu is served every day during the week, which would reduce your number of rows to 3 instead of 7.)

Your code interpreter can translate day # and hours without the need for ancillary tables.

SELECT R.name 
FROM Restaurant R 
INNER JOIN Menu M 
ON R.Id = M.RestId 
INNER JOIN Food F 
ON F.MenuId = M.Id 
WHERE F.Name = "The Meal"

(Note the lack of use of F.RestId)

‘Food’ is perhaps a misnamed table, as it more accurately represents ‘Dish’ or ‘MenuItem’, and ‘Stuff’ would be ‘Ingredient’, but that’s just playing with names.


#7

especially tables with auto_increment ids


#8

If I got it right, then my tables will look like this:

Place

Id
Name

Menu

Id
Name
PlaceId

Food

Id
Name
MenuId

MenuTimes

Id
MenuId
DayStart
DayEnd
TimeStart
TimeEnd

and Thanks for the help in choosing the name of the tables:blush: