Hi all, I've finally been given approval to create a new timesheet system - which will replace our 15year old access database. I'm creating the tables now, and one of the things we need is a default schedule so to speak. This just needs to be the day of the week and the number of hours that day.
Say for example I work Monday 9-5 and Wednesday 9-3 and someone else works 9-5 M-Th. Since this sounds like a classic one to many relationship I thought it should go in its own table. Currently my table definition that I'm planning to use is:
CREATE TABLE `Emp_Schedule` (
-- Primary Key: id
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
-- Foreign Key references Employees.id
`emp_id` INT UNSIGNED NOT NULL,
-- Schedule info, by day
`weekday` ENUM('Monday','Teusday','Wednesday','Thursday','Friday'),
`hours` DECIMAL(2,2),
-- Indexes
PRIMARY KEY(`id`),
INDEX `emp_id` (`emp_id`),
FOREIGN KEY (`emp_id`) REFERENCES `Employees`(`id`)
ON DELETE CASCADE ON UPDATE CASCADE
) Engine=InnoDB;
I was wondering if you guys thought ENUM was the best way to store the day. This is a set schedule so it doesn't need to be unique to a specific day in time, but rather the day of the week. I thought about using varchar, but with only 5 possibilities (Office is closed on the weekend, so no scheduled workers) that didn't seem like the best choice.