Results 1 to 2 of 2
- 08-06-2011, 01:07 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 18
- Rep Power
- 0
comparing times/schedule algorithm
Hi!
I want to make a TV Guide application. I havent started real coding yet as i am still trying to think through some points of it. I have a question about time handling. User can add new TV channel and if it's added he later can add programs to it. Channels and programs are stored in a different SQL tables(i'm going to use PostgreSQL).
When user try-s to add some new programm to certain channel, I somehow have to determine that there-s nothing allready on, on that time and if there is, it has to send an error to user. Problem is that i don't know how to do it.
It would be easy if the previously stored program would start in exactly the same time as the new program user would to add, then a simple SQL query would do the trick. But that isnt allways the case.
Let's say that user tries to add a show(duration 1 hour) on Channel1 that would start 16:00 at Monday. But there could be allready a show that starts 13:00 and lasts for 7 hours or there could allready be a show that starts 16:30.
My question is what are my options to handle this problem? Should it be done in a database or should it be done in Java. Sure there is a robust way to query all the programs that are on that specific channel on that specific day and then do some math in java but isnt there a cleaner way?
Something like fetch me two programs from db that are closest(1 before, 1 after) to the starting time of the program user likes to add.
One restriction that i have is that TV_program table can have only these fields:
Primary key
Name
Genre
Starting time
Duration
Foreign key of the channel that it's related to.
- 08-06-2011, 04:05 PM #2
Member
- Join Date
- Aug 2011
- Posts
- 13
- Rep Power
- 0
Similar Threads
-
comparing Graphs and Comparing Matrix
By jetnor in forum New To JavaReplies: 0Last Post: 03-27-2011, 01:40 AM -
Calendar application to schedule vacations
By tirwit in forum New To JavaReplies: 8Last Post: 09-16-2010, 05:44 PM -
Programming NFL Schedule
By PhilArmstrong in forum New To JavaReplies: 0Last Post: 03-04-2010, 02:52 PM -
Java Schedule program
By jaysyshaw in forum New To JavaReplies: 0Last Post: 01-13-2010, 12:07 AM -
How to schedule a job in java
By Malathi in forum Web FrameworksReplies: 4Last Post: 03-27-2009, 10:14 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks