jmr3460 Posted April 11, 2010 Share Posted April 11, 2010 I am working on a site that will allow users to schedule events for one week at a time. Each day they can schedule an opening and closing time. My current table is structured like this: `event_id` int(3) unsigned NOT NULL AUTO_INCREMENT, `user_id` int(3) NOT NULL, `date_start` varchar(10) NOT NULL, `day1_open` varchar(10) NOT NULL, `day1_close` varchar(10) NOT NULL, `day2_open` varchar(10) NOT NULL, `day2_close` varchar(10) NOT NULL, `day3_open` varchar(10) NOT NULL, `day3_close` varchar(10) NOT NULL, `day4_open` varchar(10) NOT NULL, `day4_close` varchar(10) NOT NULL, `day5_open` varchar(10) NOT NULL, `day_5close` varchar(10) NOT NULL, `day6_open` varchar(10) NOT NULL, `day6_close` varchar(10) NOT NULL, `day7_open` varchar(10) NOT NULL, `day7_close` varchar(10) NOT NULL, After looking at scripting from this table it is looking a little difficult. My question is, "Can anyone suggest a more simpler structure?" Thanks for any ideas. Quote Link to comment https://forums.phpfreaks.com/topic/198229-daily-openings-and-closings/ Share on other sites More sharing options...
Mchl Posted April 11, 2010 Share Posted April 11, 2010 Have one table for event data like: eventID, name, dateStart, dateEnd (BTW, use DATE type for storing dates) and another to store information about opening and closing times like eventID, day (DATE), openTime, closeTime (again, use TIME for storing times) Quote Link to comment https://forums.phpfreaks.com/topic/198229-daily-openings-and-closings/#findComment-1040111 Share on other sites More sharing options...
jmr3460 Posted April 15, 2010 Author Share Posted April 15, 2010 Thanks for the reply, All of the events are the same, just different addresses. (I am getting the location from the users profile.) I created two new tables (event, open_close). This is the information for the tables I have now. CREATE TABLE IF NOT EXISTS `event` ( `event_id` int(3) unsigned NOT NULL AUTO_INCREMENT, `user_id` int(3) NOT NULL, `date_start` date NOT NULL, `date_end` date NOT NULL, PRIMARY KEY (`event_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; CREATE TABLE IF NOT EXISTS `open_close` ( `open_id` int(3) unsigned NOT NULL AUTO_INCREMENT, `event_id` int(3) NOT NULL, `day` date NOT NULL, `open_time` time NOT NULL, `close_time` time NOT NULL, PRIMARY KEY (`open_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; I have in the past had a little trouble converting mysql time to php time but I will see what it takes and conform. I do want to do it the best way. I am going to do this in a two step process, but that is probably a php thing so I will bring that up their if I have any problems with that. Thanks for any and all of your help. Quote Link to comment https://forums.phpfreaks.com/topic/198229-daily-openings-and-closings/#findComment-1042161 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.