One thought that comes to mind is to keep two tables. One would hold the schedules like you have above, the other would hold the times and who is scheduled for those times. Then when you added a new schedule, try and insert it into the second table (probably 1 record for your smallest segment of time), if you succeed then the rule is okay, otherwise force the user to retry. An alternative would be to build an insert trigger that does similar checking for you when you attempt to insert a record. The advantage of the first idea is that you can easily use your second table to generate a view that will show any gaps in the schedules as well as disallowing overlaps.


___________
Eric Hodges

In reply to Re: Managing a on-call Calendar by eric256
in thread Managing a on-call Schedule by Herkum

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.