I was thinking that someone knows how to know where the restaurant is "open now" I am developing a similar application using html / javascript / php. I was going to have a column for each day in my database, in which the "2243" format (10:43 pm) was the hours separated by commas. So for example, if a restaurant lunch is open for lunch and dinner it "1100,1400,1700,2200" Maybe I'll check) using (JS If the current time for the current day falls in a range I want to be able to set them too I think I checked will overlap with open some borders the "late open", etc. "open tonight" if a restaurant Are.
Is there a better way to do this? Specifically, how to store hours in the database and then it determines, then they overlap with a given set of hours.
Thank you.
You definitely want to make the database new. Putting multiple values in one column, such as a major violation of the rules of generalization, will cause many headaches under the road. A column should always keep a piece of information.
You should use the appropriate data type, do not put time in a string, because you can end up with "FU" as a timeline, and then what do you do?
Instead, you might want to do:
CREATE TABLE Restaurants (restaurant_id INT NOT NULL, RESTAURANT_NAME VARCHAR (40) NOT NULL, constraint PK_Restaurants primary key cluster (restaurant_id )) table Restaurant_Hours (restaurant_id INT nOT NULL, hours_id INT nOT NULL, DAY_OF_WEEK NULL not SMALLINT, Start_time time produces NULL, - depending on your RDBMS and supports not NULL date / time datatypes it end_time time constraint PK_Restaurant_Hours Primary key cluster (restaurant_id, hours_id))
Check the restaurants open at a certain time:
R.restaurant_id, R.restaurant_name where selection Restaurants R exists (select Restaurant_Hour * s RH Where RH.restaurant_id = R.restaurant_id and RH.start_time & lt; = @time and RH.end_time & gt; = @time and RH.day_of_week = @day_of_week)
If you have a slot of a time spread at midnight You need two lines - one for the first day and another for midnight - next to the "x" Also, consider using the time zone while using a GUI. Remember to keep.
Comments
Post a Comment