Top level calendar (i.e Customer service schedule record) has a set of calendarrules. One of those rules is a recurring rule, and other rules defines the deviation from the recurring rule.
So a Calendar which weekly schedule type is set as same all day, There is only one calendar rule associated with top level calendar.
But a caleandar that varies by day, We see separate rule for days where work hours differ apart from a recurring rule ..
Each of these recurring rules are associated with their innercalendar, and each of these innercalendar are associated with calendarrules defining the work hours for the day.
So there are 4 layers of calendar and calendar rules.
Top Layer (First Layer) – Calendar: The calendar that holds the name , type and associate holiday schedule.
Second Layer – Calendar Rules: Describing the pattern (recurring or sub rule), that defines what days the rule is valid for.
Third Layer – calendar (inner): this is inference from second layer calendar rules to 4th layer calendar rules
Fourth Layer – calendar rules : Describe the work hours of a given day (at 2nd layer)
Number of calendarrules at 4th layer for a given innercalendarid depends on number of breaks in the work hours for the day.
If there are no breaks, there are only one rule per innercalendar id, the rule has offset from 00:00 hours and duration as number of minutes user is supposed to work
If there are breaks, apart from above rule, we have rules for break that also specifies the offset of break from 00:00 hours and duration of the break in minutes.
So if there are 2 breaks , there will be 1 work hour rule and 2 break rules for every inner calendar ids.