PHP/Mysql Recurring Event Pattern for WordPress plugin

Job ID: 32099789

Budget: $30 – $250 USD

I'm currently working on a WordPress event booking plugin for a client website. I can write 95% of the plugin but where I'm struggling is writing a pattern for recurring events that can be stored in the database so that when a user creates a recurring event, instead of creating a row in the database for every occurrence of the event (which seems very inefficient), this pattern can be used to auto-populate the calendar on the fly.

When a user edits an instance of a recurring event, that instance will then be entered as it's own row in the database (which I can write the code for, that's no problem).

I can do the simple occurrences like "every month on the 15th" or "every Thursday" but where I'm struggling is options like "every 2nd Tuesday of the month" or "repeat every X weeks on Wednesday".

After many hours going through StackOverflow posts, I just need help understanding the best way to create and also parse this pattern when I retrieve it from the database.
Related categories: PHP WordPress MySQL Database Design