0

I've successfully integrated the answer from this question: Calendar Recurring/Repeating Events - Best Storage Method

However, now one issue comes to mind. What if a user would like to edit a single event occurrence in the series? Or delete an event occurrence. This needs to be handled on its own instead of linking back to its parent id. Or for instance, if a user wants to leave a note on a specific occurrence...

The only thing that I can think of at the moment is to store every single recurring event in its own row, which i don't think is a very good idea.

Unable to find an alternative to this however. I wanted to get opinions from a theory perspective not a specific sql or programming language.

simon.ro
  • 2,984
  • 2
  • 22
  • 36
user1027620
  • 2,745
  • 5
  • 37
  • 65
  • 1
    Why not have a seperate table, that can override the main table, for instance, if a record in TABLE B shows that a recurring item has been deleted or modified for the given instance, use that to determine your action else use what's in the main table. In other words, just add a record to TABLE B when something needs changed for 1 instance of a recurring item. – Ryan Wilson Apr 05 '21 at 14:13
  • Hey thanks for the quick comment, however how would you reference to the main events table? Also say the recurrence parameters changes from daily to weekly would you still be able to maintain the relationship? Say a user added a note on an occurrence on the third day and the original event was set as 'daily' recurrence. Then it was updated to weekly... – user1027620 Apr 05 '21 at 14:16
  • 1
    The change for daily to weekly would occur in the main table, as the event went from daily to weekly, else it would be deleted completely and a new record inserted as a weekly reminder. As for the note, if it was added for one instance (the 3rd day of the week), that instance would no longer occur as it was switched to weekly, so I'm not really sure how you would handle that. You could always move the note to the next notification, or maybe warn the user before allowing the change to weekly? – Ryan Wilson Apr 05 '21 at 14:23

1 Answers1

0

To accomplish this, you could introduce a new type of event, which simply adds additional data to an element belonging to an event series. Technically, you store a reference to the event series the single event occurrence belongs to. This way, you'll be able to maintain the relationship between event series and overriding event occurrences. And, in case the date/time parameters of the event series change in a way which excludes a particular event occurrence, you just remove the reference to the series from the occurrence, turning it into a single instance.

Sideways
  • 286
  • 2
  • 6
  • Thanks for the answer @Sideways. I think I understand what you're saying but I currently have two tables: 1) Events and 2) EventsMeta you're suggesting I add a new table 3) EventExceptions which has a foreign key pointing to events Id? if so, how can you specify which time/date slot to override? – user1027620 Apr 05 '21 at 14:34
  • Either by using a dedicated table or by having an additional property in the main table, in both cases you'll have the reference to the event series but of course you also need to **store the dedicated date/time** to be able to map it to a single event occurrence in the first place. – Sideways Apr 05 '21 at 14:42