可以将这 2 个数据库列合并为 1 个吗?
我有一个重复事件架构,其中包含 RecurrenceType
和 RecurrenceMultiple
列。 RecurrenceType
是具有以下选项的表的外键:(1) 无重复 (2) 每日 (3) 每周 (4) 每月。 RecurrenceMultiple
是一个整数,指示每个事件发生的重复时间范围的倍数。一些示例
- RecurrenceType=1,RecurrenceMultiple=1 :仅一次
- RecurrenceType=2,RecurrenceMultiple
- =1 :每天 RecurrenceType=3,RecurrenceMultiple=1 :每周 RecurrenceType=3
- ,RecurrenceMultiple=2 :每隔一周
- RecurrenceType=4,RecurrenceMultiple =1 : 每月
- RecurrenceType=4, RecurrenceMultiple=3 : 每第 3 个月
- RecurrenceType=4, RecurrenceMultiple=12 :每年
我想以某种方式组合这两列,以便我可以推断出 RecurrenceType ,从而允许我放弃查找表。但我想不出一个好方法来做到这一点并避免碰撞。
I have a recurring event schema that has a RecurrenceType
and a RecurrenceMultiple
column. The RecurrenceType
is a foreign key to a table that has these options (1) No Recurrence (2) Daily (3) Weekly (4) Monthly. RecurrenceMultiple
is an integer that indicates what multiple of the recurring time frame each event occurs. a few examples
- RecurrenceType=1, RecurrenceMultiple=1 : One time only
- RecurrenceType=2, RecurrenceMultiple=1 : Every day
- RecurrenceType=3, RecurrenceMultiple=1 : Every week
- RecurrenceType=3, RecurrenceMultiple=2 : Every other week
- RecurrenceType=4, RecurrenceMultiple=1 : Every month
- RecurrenceType=4, RecurrenceMultiple=3 : Every 3rd month
- RecurrenceType=4, RecurrenceMultiple=12 : Yearly
I'd like to somehow combine these two columns in a way that I can infer the RecurrenceType
allowing me to ditch the lookup table. I can't think of a good way to do this though and avoid collisions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我决定使用的方法
如果假设 0 表示没有复发,正值表示 X 天的时间跨度,负值表示 X 个月的时间跨度,则可以使用单列
RecurrenceFrequency
This is the approach I've decided to use
A single column
RecurrenceFrequency
can be used if it's assumed that 0 means no recurrence, positive values mean a timespan of X days and negative values mean a timespan of X months