Jump to content

dedicate table for days closed or not?


jimfog

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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...