SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Feb 2008
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Best way to handle date frequency

    I built an event calendar where people can post their own events. I'd like to offer an option to the user who wants to post an ongoing event. One example is a class that happens every Saturday at the same time. Another is a museum that's having an ongoing show every Monday - Friday until August 31st.

    I already have start date, start time, end date, end time as fields in the db.

    What I was thinking was a showing the user a dropdown that lets them select:

    Every (pick days)
    Every other (pick days)
    Every day

    Then show checkboxes for:

    Sunday
    Monday
    Tuesday (etc)

    Then a date field for End Date.

    My question is what is a good way to handle this in the database architecture. And what question to ask to get them to show up.
    I don't think I should create hundreds of records for the person who chooses Every Day until the end of time.
    I was hoping I could create a field for the record that showed date frequency, then ask the database the right query to get the events to show up with the others.
    Perhaps looking at my calendar would make sense. Any ideas would be very much appreciated.
    Last edited by ggeiger; Mar 22, 2013 at 08:38. Reason: re-wording

  2. #2
    SitePoint Zealot
    Join Date
    Apr 2005
    Location
    London
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think you can get the database to return you dates until end of time. You'd be better off putting that logic in your application.

  3. #3
    SitePoint Zealot
    Join Date
    Feb 2008
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    With a cut off of, say 120 new records I think the option of storing each event as a record might work best. How else would I allow users to edit an individual event in their recurring group? Data storage is cheap, and it makes some sense to do it this way.

  4. #4
    SitePoint Zealot
    Join Date
    Apr 2005
    Location
    London
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ggeiger View Post
    With a cut off of, say 120 new records I think the option of storing each event as a record might work best. How else would I allow users to edit an individual event in their recurring group? Data storage is cheap, and it makes some sense to do it this way.
    Yep maybe it is ok for your app.
    What about the scenario where they want to change the recurring event?
    For individual events you can consider 'exceptions', similar to how ics calendar files work. Again this will push more logic into your app.

  5. #5
    SitePoint Zealot
    Join Date
    Feb 2008
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jurn View Post
    Yep maybe it is ok for your app.
    What about the scenario where they want to change the recurring event?
    For individual events you can consider 'exceptions', similar to how ics calendar files work. Again this will push more logic into your app.
    I would have to offer a way for the user to edit the group, or edit a specific event, then provide a list. How to edit the group I'm not totally clear on. Perhaps I could let the first event that is entered in to the database be the parent, then insert the repeat events with a parent ID. The user would edit the parent, then I'd loop through the child events and update them as well. Perhaps skipping any child events that have a modified date, as they might have been treated as an 'exception' by the user

    It would also be easier for a user to delete a child event from the group, the scenario being they are closed that day. They could simply create the recurring events, then delete the ones they don't want.

    I don't see good examples,of this being done in available web apps (like Facebook events) and it is likely because its so hard to do it well.


Bookmarks

Posting Permissions

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