I’m working on a radio web site project based on Codeigniter.
Here is layout of the schedule:
http://postimage.org/image/nb68dfr9t/
Now, I have a progamme table. There are programme_id, programme_title, programme_content, programme_day, programme_time fields inside it.
If one programme was supposed to be on-air only 1 day of the week, I wouldn’t be in any trouble. I could easily set programme_day field to pass as a variable at Codeigniter (such like day/show/monday).
But situation is much more complicated.
One radio programme can be at only 1 day of the week, it can be at week days, it can be at weekends or it can even be at let’s say monday, wednesday and friday…
So how should I set my database fields in this case? Only one field called “Programme_day” wouldn’t be enough, I think?
What is the best practise for this?
Thank you…
1. If you want to see everything once, have a Monday, a Tuesday, etc. column., each boolean (if every day they run on the same time). Simple to retrieve data even if this looks complicated.
2. If you want the simplest solution, I say you should add the programme for every day. It’s still simple to retrieve data.
3. If you REALLY want to make it need the least space possible, assign 1 to Monday, 2 to Tuesday, 4 to Wednesday, etc., then select which days does it run in and add them and that’ll be the day value. If you use this, then it is hard to retrieve data. This is a variation of solution 1.
4. If you want a bit less space then Solution 2 requires, add a table for containing all details except time and one containing only days and times (and ID of course).
In my opinion, I’d go for solution 2, that makes possible to schedule programmes on different times every day and needs no changes. Or if you want less space to be used, you could try solution 4. Solution 1 has some advantages as well, but that has less functionality then 2 and 4. Solution 3 has the same problems as Solution 1, but it’s overly complicated (but needs less columns so a bit less complicated in structure). But I still say solution 2 or solution 4 work the best.