Frage

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.

War es hilfreich?

Lösung

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

  • 0 : One time only
  • 1 : Every day
  • 7 : Every week
  • 14 : Every other week
  • -1 : Every month
  • -3 : Every 3rd month
  • -12 : Yearly
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top