Reputation: 311
I have a project where users have personal calendar. In Calendar user can create chats, write notes, save files and etc. It's somethig like google calendar. So we have two tables Users and Calendar( it's tables of dates and link table for another entity (notes, files and etc) ). DB structures looks like
But here we have some problem. For one user we generate 365 rows in calendar(or 366 in leap year) so if we have 100 users we have to generate 36500 rows per one year.. i think its not a good way. Can u recommend me good way to solve that problem?
Upvotes: 3
Views: 5531
Reputation: 48236
You don't want to store a row for every day of the year. That's redundant if a user doesn't have an event that day, and doesn't work if they have more than one event that day.
A user hasMany (or one) calendars
A calendar hasMany events
An event starts at a datetime and ends at a datetime
(or starts at a date and ends at a date and is an allDay event)
You'll probably find that you need recurring events at some point, in which case things get complicated quickly. For this, use RFC 5545 RRules and ExRules and create "virtual" events using a materialized view.
Upvotes: 1