Results 1 to 2 of 2
  1. #1
    s3ib is offline Member
    Join Date
    Dec 2010
    Posts
    18
    Rep Power
    0

    Default 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.

  2. #2
    delican is offline Member
    Join Date
    Aug 2011
    Posts
    13
    Rep Power
    0

    Default

    you must design reboust database design and constraints. don't code constraints in java code or use class to gather everything.

Similar Threads

  1. comparing Graphs and Comparing Matrix
    By jetnor in forum New To Java
    Replies: 0
    Last Post: 03-27-2011, 02:40 AM
  2. Calendar application to schedule vacations
    By tirwit in forum New To Java
    Replies: 8
    Last Post: 09-16-2010, 06:44 PM
  3. Programming NFL Schedule
    By PhilArmstrong in forum New To Java
    Replies: 0
    Last Post: 03-04-2010, 03:52 PM
  4. Java Schedule program
    By jaysyshaw in forum New To Java
    Replies: 0
    Last Post: 01-13-2010, 01:07 AM
  5. How to schedule a job in java
    By Malathi in forum Web Frameworks
    Replies: 4
    Last Post: 03-27-2009, 11:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •