I'm working on a project that will require me to implement a calendar. I'm trying to come up with a system that is very flexible: can handle repeating events, exceptions to repeats, etc. I've looked at the schema for applications like iCal, Lotus Notes, and Mozilla to get an idea of how to go about implementing such a system. Currently I'm having trouble deciding what is the best way to handle exceptions to repeating events. I've used databases quite a bit but don't have a ton of experience with really optimizing everything so I'm not sure which method of the two I'm considering would be optimal in terms of overall performance and ability to query/search:

我正在开展一个需要我实施日历的项目。我正在尝试提出一个非常灵活的系统:可以处理重复事件,重复例外等等。我已经查看了iCal,Lotus Notes和Mozilla等应用程序的模式,以了解如何开始实施这样一个系统。目前我无法确定处理重复事件异常的最佳方法。我已经使用了相当多的数据库,但没有真正优化所有内容的经验,所以我不确定我所考虑的两种方法在整体性能和查询/搜索能力方面都是最优的:

  1. Breaking the repeating event. So taking the changing the ending date on the current row for the repeating event, inserting a new row with the exception, and adding another row continuing the old sequence.
  2. 打破重复事件。因此,在重复事件的当前行上更改结束日期,插入带有异常的新行,并添加继续旧序列的另一行。
  3. Simply adding an exception. So adding a new row with some field that indicates it as an override.
  4. 只需添加例外。因此添加一个新行,其中一些字段指示它为覆盖。

So here is why I can't decide. Method one will result in a lot more rows since each edit requires 2 extra rows as apposed to only one row by the second method. On the other hand I think the query to find an event would be much simper, and thus possibly faster(?) using the first method. The second method seems like it will require more calculating on the application server since once you get the data you'll have to remove the intersection of the two rows. I know databases are often the bottleneck for websites and while I'm sure a lot of you are thinking either is fine because your project will probably never get large enough for the difference in efficiency to really matter, I'd still like to implement the best solution. So what method would you guys pick, or would you do something completely different?

所以这就是我无法决定的原因。方法一将导致更多的行,因为每个编辑需要2个额外的行,因为第二个方法仅与一行相关联。另一方面,我认为查找事件的查询会更简单,因此使用第一种方法可能更快(?)。第二种方法似乎需要在应用程序服务器上进行更多计算,因为一旦获得数据,就必须删除两行的交集。我知道数据库通常是网站的瓶颈,而且我相信很多人都认为要么很好,因为你的项目可能永远不会变得足够大,效率差异真的很重要,我还是想实现最佳方案。那么你们选择哪种方法,或者你会做一些完全不同的事情?

Also, as a side note I'll be using MySQL and PHP. If there is another technology that you think would be better suited for this, especially in the database area, please mention it.

另外,作为旁注,我将使用MySQL和PHP。如果您认为其他技术更适合这种技术,尤其是在数据库领域,请提及它。

Thanks for the advice.

感谢您的建议。

2 个解决方案

#1


0

Events are not permanent, are subject to change or termination.

事件不是永久性的,可能会发生变化或终止。

You should insert a row for each date in the event and, upon editing a repeated event, give the option to edit all instances of the event or just one.

您应该为事件中的每个日期插入一行,并在编辑重复事件时,提供编辑事件的所有实例或仅编辑一个事件的选项。

When doing this, you should really only need an extra field to indicate if the event is active or not.

执行此操作时,您实际上只需要一个额外的字段来指示事件是否处于活动状态。

When properly indexed, this will not make a considerable difference on your queries.

正确编制索引后,这不会对您的查询产生很大影响。

An example would be:

一个例子是:

SELECT * FROM events WHERE event_id = 123 AND active = 1;

On which case you'd be required to index the event_id and active columns.

在这种情况下,您需要索引event_id和活动列。

更多相关文章

  1. 向数据库添加1的PHP Onclick事件(SQL)
  2. hibernate(*.hbm.xml)中新添加的字段被标记为红色(找不到)的解决方法
  3. Linux安装MySQL的两种方法 先卸载之前版本
  4. linux安装apache/mysql/php的最新完整方法(cents和ubuntu都实用)
  5. 获取项目列表的更好方法:缓存序列化数据与数据库查询或其他?
  6. cpanel导入大数据库(mysql)的方法
  7. mysql的count方法详解
  8. 通用的增删改查方法(反射)附带MySQL数据库连接
  9. php将图片以二进制形式保存到mysql数据库的解决方法

随机推荐

  1. Android(安卓)EditText 状态切换
  2. PC监控通过网络数据监控ANDROID屏幕
  3. Android线程模型解析(包括UI的更新)
  4. Android程序开发的环境配置
  5. android 返回键与finish区别 onBackPress
  6. AndroidManifest.xml--android系统权限定
  7. 对于android触摸事件模型的一些理解
  8. 单线程模型中Message、Handler、Message
  9. Android 自定义View
  10. 手机敲命令利器---Android Terminal