Table: Schedule_Item_Assignment
Columns
Name | Type | Constraints | Description
schedule_item_assignment_KEY | int | NOT NULL |
update__staff_KEY | int | NOT NULL |
staff_KEY | int | NOT NULL | Which staff is assigned.
schedule_item_KEY | int | NOT NULL | Which schedule item this assignment is for.
budgeted_hours | decimal (9, 2) | NOT NULL | Must be greater than or equal to zero, or -1.00 (to indicate assignment only without a budget.)
schedule_item_assignment_rank | int | NOT NULL | This is a ranking per [staff_KEY] of which schedule items to do first. Duplicates are allowed to reduce concurrency issues. A value of 999999999 indicates the assignment is not ranked.
is_primary_assignment | bit | NOT NULL | Exactly one record per [schedule_item_KEY] should be set to true.
create__changeset_KEY | int | NOT NULL |
update__changeset_KEY | int | NOT NULL |

Primary key
Name | Columns | Description
PK_Schedule_Item_Assignment$staff_KEY$schedule_item_KEY | staff_KEY, schedule_item_KEY | CLUSTERED
Unique constraints
Name | Columns | Description
UK_Schedule_Item_Assignment$schedule_item_assignment_KEY | schedule_item_assignment_KEY | This is the old ptimary key for backwards compatibility until the schedule_item_assignment_KEY can be removed.
Indexes
Name | Columns | Description
IX_Schedule_Item_Assignment$schedule_item_assignment_rank@schedule_item_KEY@staff_KEY | schedule_item_assignment_rank, schedule_item_KEY, staff_KEY | This index helps compute schedule_item_assignment_active_rank because that is only computed when schedule_item_assignment_rank is less than 999999999.
IX_Schedule_Item_Assignment$schedule_item_KEY$staff_KEY@@@ | schedule_item_KEY, staff_KEY, budgeted_hours, is_primary_assignment, schedule_item_assignment_KEY, schedule_item_assignment_rank, update__staff_KEY | This is unique by schedule_item_KEY and staff_KEY and includes all the other columns of the table so that it covers all queries by schedule_item_KEY.

Foreign keys
Name | Columns | Referenced table | Description
FK_Schedule_Item_Assignment__Schedule_Item__schedule_item_KEY | schedule_item_KEY | Schedule_Item | on delete cascade;
FK_Schedule_Item_Assignment__Staff__staff_KEY | staff_KEY | Staff | on delete cascade;