如何为Google日历设计桌面结构,如重复功能? [英] How to design table structure for Google Calendar like Repeat feature?

查看:227
本文介绍了如何为Google日历设计桌面结构,如重复功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以最佳方式为Google日历设计表格结构,例如重复功能?

How to design table structure in a best possible way for Google Calendar like Repeat feature?

Google日历可让用户安排重新发生事件无限期或确定一段的时间。现在当我们这样做时,数据库表中管理这些类型的未来数据的最佳方法是什么?

Google calendar lets user schedule re-occurrence of an event for indefinite or definite period of time. Now when we do that what is the best way to manage these type of future data in database tables?

例如:我有表名为事件,我存储所有常规事件这是非重复类型,并且安排了一些日子和时间。现在,当涉及重复发生的事件时,我将创建一个单独的表并将其存储为模板?

For example: I have table called events where I store all regular events which are of non-repeat type and scheduled for some day and time. Now when it comes to events which are reoccurring shall I create a separate table and store it as a template?

例如,让我们来看一下这个:

For example let’s take it very simple:

**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-job或者调度程序可以为下一个事件创建一个事件。如果要在日历上显示,可以通过从 Event_Schedule 表生成数据来完成,如果用户编辑未来事件的数据,我们可以将该事件的数据存储在事件表。
它是正确的方式还是可以以更好的方式完成?我可以想到将它存储在与模板相同的表中,但是我发现一个单独的表是更好的方法。

Fields are not complete but this is just to give some idea and what I can do here is a cron-job or scheduler can create an event every for next occurrence. If it comes to displaying it on calendar it can be done by generating data from Event_Schedule table and if user edits data for future event we can store data for that event in Events table. Is it the right way or it can be done in a better way? I could think of storing it in the same table as a template but I find a separate table as better approach.

推荐答案

您的数据库不用做任何事情您的程序代码可以负责某些日历呈现。

Your database doesn't have to do everything. Your program code can be responsible for some of the calendar rendering.

这是Event数据库表的一个版本。

Here's one version of the Event database table.

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)

您的程序将负责查看事件表的事件行,查看哪些行具有重复频率,以及计算在显示的月份中显示哪些事件。

Your program would be responsible for going through the event rows of the Event table, seeing which ones have a repeat frequency, and calculating which events would be displayed in the month being displayed.

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

Basically, your program code would have to calculate the following program object. This is not a database table.

Calendar Event
--------------
Event Date
Event Start Time
Event End Time
Event Title
Event Location
Event Description.

您将显示正在显示月份的日历活动列表或数组。

You would have a list or array of calendar events for the month being displayed.

这篇关于如何为Google日历设计桌面结构,如重复功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆