对于允许安排约会(重复发生和单次)的可用性日历来说,最好的数据库架构是什么?
在我的应用程序中,我有一个有时间表的提供商和根据时间表进行预约的客户。我需要以下功能。
提供商: - 能够指定重复出现的可用性。例如周一 9-5、周二 10-3 等。 - 能够屏蔽数据。例如 - 周一不可用。 - 能够添加单个、不重复出现的日期/时间段。例如 - 本周六 9 点至 5 点。
顾客: - 能够预订单次约会。 - 能够预订重复的约会。 (每周一 9 点至 4 点)。
到目前为止,我提出了 3 个选项:
- 将时间表划分为 30 分钟的间隔,并为每个间隔/提供商对创建一个数据库条目。每个间隔都可以免费或预订。当客户预约时,我们会将时间间隔标记为已预约。这种方法的问题在于它浪费了大量空间,而且我不确定重复预订的搜索性能有多好。
- 将每个可用时段保存为“事件”。如果再次发生,请重复该事件。搜索空闲时段时,请搜索预订表以确保没有重叠预订。在这种情况下,搜索重复出现的槽位似乎有点尴尬。要查找明年 9 日至 5 日星期一可用的所有提供商,我们必须搜索所有匹配的“事件”并查找具有 52 个匹配事件的所有提供商。
- 将每个可用时段保存为“事件”。如果重复发生,请添加标记。搜索空闲时段时,搜索预订表以确保没有重叠预订。它可以更轻松地搜索重复发生的约会。为了“屏蔽”应该重复出现的时段,我们可以插入一个假预订。
In my application I have a provider that has a schedule and clients that book appointment from the schedule. I need the following features.
Provider:
- Be able to specify reoccurring availability. For example Mon 9-5, Tues 10-3, etc.
- Be able to black out datas. For example - not available on this Mon.
- Be able to add single, not reoccurring dates/times slots. For example - This Sat 9-5.
Customer:
- Be able to book single appointments.
- Be able to book reoccurring appointments. (Every Mon 9-4).
So far I came up with 3 options:
- Divide the schedule into 30 min intervals and create a database entry for each interval/provider pair. Each interval can be either free or booked. When a customer books an appointment we mark the intervals as booked. The problem with this approach is that it wastes a lot of space, and I am not sure how good the search performance would be for a reoccurring booking.
- Save each availability period as an "event". If it is reoccurring, duplicate the event. When searching for free slots search the booking table to make sure that there is no over lapping booking. In this case, searching for reoccurring slots seems a bit awkward. To find all the providers that are available on Mon 9-5 for the next year we will have to search for all the matching 'events' and find all the providers that have 52 matched events.
- Save each availability period as an "event". Add a flag if it is reoccurring.When searching for free slots search the booking table to make sure that there is no over lapping booking. It makes it easier to search for reoccurring appointments. To "black out" slot that are suppose to be reoccurring we can just insert a fake booking.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1.创建事件表:
a) 包含基本列事件日期、开始时间、结束时间以及事件的其他详细信息 - 这些是繁忙时间,因此是您在日历上屏蔽的时间
b) 重复事件 - 添加列:
- 重复 - 默认为 0
- 重复类型(每日、每周、每月)
- recurvery(复发发生时间的计数)
- 周一、周二、周三、周四、周五、周六、周日 - 每周重复的一周中的几天
- 月和日 - 用于每月重复
2. 在日历上创建重复事件时会遇到挑战:
- 如果您一次创建所有这些(例如接下来的 6 个月),则每当您编辑其中一个时,其他的都必须更新
- 如果您仅在前一个事件过去后才创建事件,那么您需要复杂的逻辑来显示未来日期的日历
3.您还需要规则来处理事件是否允许彼此重叠、要使用哪些资源,可以提前多长时间安排活动
1.Create a event table:
a) With the basic columns eventdate, starttime, endtime, with other details for the event - these are the busy times so are what you block out on the calendar
b) Recurring Events - add columns:
- isrecurring - defaults to 0
- recurrencetype (daily, weekly, monthly)
- recurevery (a count of when the recurrence will occur)
- mon, tue, wed, thur, fri, sat, sun - days of the week for weekly recurrence
- month and dayofmonth - for monthly recurrence
2.The challenge comes when creating the recurring events on the calendar:
- if you create all of them at once (say for the next 6 months), whenever you edit one the others have to be updated
- If you only create an event when the previous one has passed then you need complex logic to display the calendars for future dates
3.You also need rules to take care of whether events are allowed to overlap each other, what resources are to be used, how far ahead the events can be scheduled