Database design 如何为类似谷歌日历的重复功能设计表结构?

Database design 如何为类似谷歌日历的重复功能设计表结构?,database-design,Database Design,如何为类似谷歌日历的重复功能以最佳方式设计表结构 谷歌日历允许用户在不确定或确定的时间内安排事件的重新发生。现在,当我们这样做时,在数据库表中管理这些类型的未来数据的最佳方法是什么 例如:我有一个名为events的表,其中我存储了所有非重复类型的常规事件,并安排在某一天和某一时间。现在,当涉及到重复发生的事件时,我是否应该创建一个单独的表并将其存储为模板 例如,让我们非常简单: **Events** id title description datetime_from datetime_to s

如何为类似谷歌日历的重复功能以最佳方式设计表结构

谷歌日历允许用户在不确定或确定的时间内安排事件的重新发生。现在,当我们这样做时,在数据库表中管理这些类型的未来数据的最佳方法是什么

例如:我有一个名为events的表,其中我存储了所有非重复类型的常规事件,并安排在某一天和某一时间。现在,当涉及到重复发生的事件时,我是否应该创建一个单独的表并将其存储为模板

例如,让我们非常简单:

**Events**
id
title
description
datetime_from
datetime_to
status


**Event_Schedule**
id
title 
description
time_from
time_to
repeats_on (Daily, Weekly, Monthly)
repeat_config ____serialized array or object
字段是不完整的,但这只是给一些想法,我可以在这里做的是一个cron作业或调度器可以为下一次事件创建一个事件。如果要在日历上显示它,可以通过从
Event\u Schedule
表生成数据来完成,如果用户编辑未来事件的数据,我们可以将该事件的数据存储在
Events
表中。
这是正确的方法还是可以用更好的方法?我可以考虑将其作为模板存储在同一个表中,但我发现一个单独的表是更好的方法。

您的数据库不必做所有事情。您的程序代码可以负责一些日历渲染

下面是事件数据库表的一个版本

Event
-----
Event ID
Event Title
Event Location
Event Description
Event Start Time Stamp
Event End Time Stamp
Repeat Frequency (None, Daily, Weekly, Monthly, Quarterly, Yearly, 
    every nth day (every 3rd Tuesday)
    other odd frequencies 
        (the Tuesday following the first Monday in November, the Sunday 
         following the paschal full moon, which is the full moon that 
         falls on or after the vernal (spring) equinox)
Calendar Event
--------------
Event Date
Event Start Time
Event End Time
Event Title
Event Location
Event Description.
您的程序将负责遍历事件表中的事件行,查看哪些行具有重复频率,并计算在显示的月份将显示哪些事件

基本上,您的程序代码必须计算以下程序对象。这不是一个数据库表

Event
-----
Event ID
Event Title
Event Location
Event Description
Event Start Time Stamp
Event End Time Stamp
Repeat Frequency (None, Daily, Weekly, Monthly, Quarterly, Yearly, 
    every nth day (every 3rd Tuesday)
    other odd frequencies 
        (the Tuesday following the first Monday in November, the Sunday 
         following the paschal full moon, which is the full moon that 
         falls on or after the vernal (spring) equinox)
Calendar Event
--------------
Event Date
Event Start Time
Event End Time
Event Title
Event Location
Event Description.

您将看到一个月的日历事件列表或数组。

谢谢@gilbert le blanc,这很有意义。对不起,我回答了很长时间,但这并没有改变答案是正确的。