llazzaro / django-scheduler

A calendaring app for Django.
BSD 3-Clause "New" or "Revised" License
1.3k stars 393 forks source link

How to model for both place and user? #543

Open xjlin0 opened 2 years ago

xjlin0 commented 2 years ago

Thanks for creating such a great package to track down time events. Could anyone know how to model the following scenario? I am looking for a way to not overbooking a room.

Let's say there is a building have meeting room 2 and room 3, and user A & B. How can each room has its own calendar so users can find what time's vacant? Also there's a need to show all bookings of the entire building. Currently there's only one event(id: 100) but more will come.

My current thinking: 5 calendars A main calendar (calendar id 1), room 2 calendar (calendar id 2), room 3 calendar (calendar id 3) user A calendar (calendar id 4), user B calendar (calendar id 5)

For now only one event: Event(id: 100, calendar: 1) <== this link event to main calendar

EventRelation to link event to both user and room EventRelation(event: event100, object: room 2 or 3, distinct: 'place') EventRelation(event: event100, object: user A or B, distinct: 'user')

And Room or User can have their own calendar via Calendar Relation.

erDiagram
    Event ||--|| MainCalendar: model
    Event ||--|{ Room: EventRelation
    Event ||--|{ User: EventRelation
    Room ||--|| RoomsCalendar: CalendarRelation
    User ||--|| UsersCalendar: CalendarRelation
    Event {
    id I00
    calendar I
    }
    MainCalendar {
    id I
    }
    RoomsCalendar {
    id for2or3
    }
    UsersCalendar {
    user forAorB
    }
    Room {
    id room2or3
    }
    User {
    id userAorB
    }

The problem is the very same meeting now have 3 copies. Say a meeting at Tuesday 10AM, it will have event on main calendar, room calendar and user calendar. If meeting changes we need to change all three Events. Please let me know the best way to model this. thanks!