Jump to content

dedicate table for days closed or not?


Recommended Posts

I have a table that stores the hours of the week a business(hair salon for example) is open monday 11:00 to 18:00 tuesday etx so on so on

CREATE TABLE `store_open` (
  `id` int NOT NULL AUTO_INCREMENT,
  `b_user_ID` mediumint unsigned DEFAULT NULL,
  `open_time` time DEFAULT NULL,
  `close_time` time DEFAULT NULL,
  `open_time_b` time DEFAULT NULL,
  `close_time_b` time DEFAULT NULL,
  `day` tinyint DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `b_user_ID` (`b_user_ID`),
  KEY `day_idx` (`day`),
  CONSTRAINT `day` FOREIGN KEY (`day`) REFERENCES `weekdays` (`dayID`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8

the day foreign key refrences this table here..which holds the days of the week,

CREATE TABLE `weekdays` (
  `dayID` tinyint NOT NULL AUTO_INCREMENT,
  `days` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`dayID`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8

QUESTION...

I must also store the days where the business will be closed...do you think a separate table for that is needed?

Which I assume this table will have a foreing key referencing the weekdays table....

OR you think is better to add another column  to the store_open table(probably a boolean-closed or no closed)

In that last scenario the days that the business will be closed the values of open_time,close_time(see the store open table create statement) will be set to null.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...