2

I'm using this method to store calendar events. Basically storing events not as dates, but as a repeating pattern. Suppose i have events that take place every other day starting from today and some events take place every week on tuesday, starting next week.
The problem with this approach is when entering a new event and how to determine, that no two events will overlap. Some events will have a start, repeat interval, but no repeat stop so how do i compare two such events? I don't want a person to enter a recurring event at the same time another one is already happening.
So my question is, how to make sure with this approach that no two events will overlap?

Thanks in advance

Community
  • 1
  • 1
user2950735
  • 31
  • 1
  • 3
  • Two questions: Do you have performance issues? Do you want to test that that two events will never overlap "forever" or just within a reasonable range like "next year", or "next decade"? – Fumidu Apr 27 '15 at 08:45
  • Which dbms? (Date/time functionality is often dbms specific...) – jarlh Apr 27 '15 at 09:36
  • Technically i would like to know whether they will never overlap, but if that is not possible i suppose a reasonable time range would work. I use mysql – user2950735 Apr 28 '15 at 07:15
  • possible duplicate of [Algorithm: how to check intersections of recurring events definitions?](http://stackoverflow.com/questions/2904087/algorithm-how-to-check-intersections-of-recurring-events-definitions) – Nanne Apr 28 '15 at 07:16
  • I'm not aware of any algebraic solution to when a monthly event will intersect a weekly event; both the varying length of a month and the complexities of leap years interfere too much. You're going to be forced to project your patterns in to the future (probably easier to do in your app rather than sql, but possible with recursive CTE) and then check for intersections. But it should probably be noted; any regular event (every n seconds) WILL eventually intersect any repetition involving months - it's WHEN rather than IF. – MatBailie Apr 28 '15 at 07:26
  • The repetitions will be daily: no less than daily interval. It's every n days where n is an integer. n could be 1 or 60 days, whatever. Isn't this then just a problem of finding where two sets will meet? If i have two interval (a = 3 b = 20) sets starting at 0 and each repeats after a certain time, then their first meeting point is where their LCM is (60). Now its when they are shifted in a way that makes this difficult. I might be completely confused though. – user2950735 Apr 30 '15 at 09:15
  • Did you get a solution for this? – hardiksa Apr 07 '20 at 04:24

0 Answers0