Db Design for Restaurant operating time

Need help in designing a db to store the operation time of a restaurant.

Opening days - monday thru sunday
Timings - closed for breaks after lunch and saturday timings etc.

Sorry to hijack your thread,

This answer my question too but how would you select day and time from the frontend?

Any idea what UI could look like for a day of week and time

day VARCHAR(9),
timestart TIME,
timeend TIME

nothing says day has to be unique.

Off Topic:

didnt quite get the part “is the best time”

just curious … whats r937… :smiley:

better to have only one table for people

no, in this case it is

PRIMARY KEY ( restid, weekday, opentime )

Thanks you.

Have another question.

There is a USER. who can tweet (status Messages )

a User can be assigned ownership of a restaurant and can tweet Rest status messages also but as a rest.

Is it better to have users seperately to rest owners or is it ok to make rest owners also as users.

CREATE TABLE opening_hours
, opentime TIME NOT NULL
, closetime TIME NOT NULL
, PRIMARY KEY ( restid, weekday, opentime )
INSERT INTO opening_hours VALUES

the sample data is for two restaurants – the first one, restaurant 21, is open 7 days a week, while the second one, restaurant 44, is open only monday-friday

i am a little confused. u mean natural key in this case is rest_id ?

two rows

thanks buddy.

the problem is… some rest open 10am to 4.30pm then 7pm to 11pm… was wondering how to accomodate that. ;(

Some rest will vary the timings according to the day. so need to accomodate that.

[ot]937 is just the sweetest number in the whole world… as well as being a prime number

9:37 is the best time, too (see my avatar)[/ot]

@r937 when should a table have an id - unique and autoincrement ?

i use it on all tables. is there a reason u havent used it in ur example ?

use a surrogate key (which is what an auto_increment is) only when there is no suitable natural key available for the purpose

As i said… day doesnt have to be unique.

The above restaurant is open from 8 AM till 12, and 2 PM til 10 on day 4 (which is… Wednesday, if my memory of the date function is accurate)