What is the best way to handle exceptions for repeating calendar events

I am working on a project that will require me to implement a calendar. I am trying to come up with a system that is very flexible: it can handle repeating events, exceptions for repeating, etc. I reviewed the schema for applications such as iCal, Lotus Notes, and Mozilla to get an idea of ​​how to get started implementing such a system. I am currently having problems resolving the issue of how best to handle exceptions for recurring events. I used the databases quite a bit, but I did not have much experience with really optimizing everything, so I'm not sure which of the two methods that I consider would be optimal in terms of overall performance and query / search ability

  • Violation of a recurring event. Therefore, accepting changes to the end date of the current line for a repeating event, inserting a new line with an exception and adding another line that continues the old sequence.
  • Just adding an exception. Therefore, adding a new line with some field that indicates its redefinition.

So that’s why I can’t decide. The first method will lead to a much larger number of lines, since each edit requires 2 additional lines, which can be attached to only one line by the second method. On the other hand, I think the query to search for an event will be much simpler and possibly faster (?) Using the first method. The second method seems to require more computation on the application server, since after receiving the data you will need to remove the intersection of the two lines. I know that databases are often the bottleneck for websites, and although I am sure many of you think this is normal, because your project will probably never get big enough for the difference in performance to really have meaning, I would still like to implement a better solution. So which method would you chooseor will you do something completely different?

, MySQL PHP. , , , , , , .

.

+3
2

, . , , , .

0

, .

.

, , .

.

:

SELECT * FROM events WHERE event_id = 123 AND active = 1;

event_id .

0

Source: https://habr.com/ru/post/1737782/


All Articles