Mehdi.Sqalli
Mehdi.Sqalli

Reputation: 510

Database Architecture Recurring Events

I am building a Database based on open and crowdsourced data. The data involves recurring scheduled events. One event is maximum 7 days long.

Users ask for the current event and the next one depending on their location and datetime. (They cannot ask for the event happening in 2 months, only the current one, and the next one)

There is always one unique event going on at a certain time and location. (You cannot have 0 events, nor 2)

Here are the issues I am facing :

How would you build your database based on these elements ?

Upvotes: 1

Views: 400

Answers (1)

Neil McGuigan
Neil McGuigan

Reputation: 48246

  1. Use RFC 5545 (iCalendar) RRules. Store them in your events table

  2. Use materialized views to generate actual events from the RRules, say +-1 month or +-1 year

If you use PostgreSQL as your database, you can use the pg_rrule extension to calculate dates based on RRules.

Upvotes: 1

Related Questions