Database design for recurring events with exceptions

后端 未结 1 1283
忘了有多久
忘了有多久 2020-12-28 20:23

I\'m building a system that needs to store/manage different types of events. For simplicity, I will focus on designing a calendar (I\'m building something slightly different

相关标签:
1条回答
  • 2020-12-28 21:14

    Use iCalendar RRules and ExDates

    If it's a recurring event, just store the start/end datetimes and RRules and ExDates for the event.

    Use a Materialized View to pre-calculate upcoming actual events, say for the next 30 days or 365 days.

    As you are using Postgres, you can use existing python, perl, or javascript RRule libraries (such as dateutil) inside pg function for calculating future events based on the rrules and exdates

    UPDATE: check out pg_rrule extension: https://github.com/petropavel13/pg_rrule

    0 讨论(0)
提交回复
热议问题