Quote:
Originally Posted by linux1880
Thanks healdem,
Could you please suggest me fields. Thanks
|
I thought I already had..
I'd follow It-iss's appraoch, except...
I'd want to store the date time a proramme starts and the date time a programme ends
why?
well I don't think the duration is as meaningful as the end time. using end time simplifies the SQL to find a current program..
Code:
SELECT My, Column, List FROM mytable
WHERE StartsAt >= now() and Now()<=EndsAt;
or better yet try the between construct.
Code:
SELECT My, Column, List FROM mytable
WHERE now() BETWEEN StartsAt AND EndsAt;
if you use the BETWEEN construct you must make certain the earliest date is shown first otherwise the results can be 'peculiar'
I'd probably name those columns StartsAt and EndsAt or somethign similar, both would be datetime values. however naming columns is always fraught with potential issues.. the name should meet your naming convention, it should adequately, uniquely and immediately describe the purpose of that column not just to you but other developers or consumers of your data. ideally it should be like reading a normal sentence. so for me calling a column 'time' is not ideal, time of what?, calling it StartsAt makes the meaning very clear, its the time the programmer starts at. with reference to the table name aswell its crystal clear
Code:
SELECT PROGRAMME.StartsAt, PROGRAMME.EndsAt FROM PROGRAMME
Personally I use 'CamelCase' where the first letter of each word comprising the column name is uppercase, others use all lower case. I use camel case as I find it makes it easier on the eye to read, but you may feel different or not have that choice.
By storing a start & end time you no longer are storing the duration, but thats not an issue as the duration is derived. To find the duration of a program use the TimeDiff function, or use an appropriate function in the front end / code driving this application.
essentially it doesn't matter whether you store starttime and a duration or start time and an end time (or for that matter a duration and end time), if you know two pieces of information you can derive the third piece. I prefer the StartsAt / EndsAt approach as it makes the SQL neater and more legible (in my books) but essentially its irrelevant. the only thing is you don't store all 3 elements. To mangle Orwell's Animal Farm: "two elements good, three elements bad"