[dbo].[LaborRatingScheduleQuery]
CREATE TABLE [dbo].[LaborRatingScheduleQuery]
(
[LaborRatingScheduleQueryID] [int] NOT NULL IDENTITY(1, 1),
[LaborRatingGroupFID] [int] NOT NULL,
[LaborRatingDayFID] [int] NOT NULL,
[StartTime] [datetime] NOT NULL,
[EndTime] [datetime] NOT NULL,
[LaborRatingTypeFID] [int] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[LaborRatingScheduleQuery] ADD CONSTRAINT [CK_LaborRatingScheduleQuery_StartTime_EndTime] CHECK (((1)=[dbo].[IsOnDayZero]([StartTime]) AND (1)=[dbo].[IsOnDayZero]([EndTime])))
GO
ALTER TABLE [dbo].[LaborRatingScheduleQuery] ADD CONSTRAINT [PK_LaborRatingScheduleQuery] PRIMARY KEY NONCLUSTERED ([LaborRatingScheduleQueryID]) ON [PRIMARY]
GO
CREATE UNIQUE CLUSTERED INDEX [IX_LaborRatingScheduleQuery_LaborRatingGroupFID_LaborRatingDayFID_StartTime] ON [dbo].[LaborRatingScheduleQuery] ([LaborRatingGroupFID], [LaborRatingDayFID], [StartTime]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[LaborRatingScheduleQuery] ADD CONSTRAINT [FK_LaborRatingScheduleQuery_LaborRatingDay] FOREIGN KEY ([LaborRatingDayFID]) REFERENCES [dbo].[LaborRatingDay] ([LaborRatingDayID])
GO
ALTER TABLE [dbo].[LaborRatingScheduleQuery] ADD CONSTRAINT [FK_LaborRatingScheduleQuery_LaborRatingGroup] FOREIGN KEY ([LaborRatingGroupFID]) REFERENCES [dbo].[LaborRatingGroup] ([LaborRatingGroupID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[LaborRatingScheduleQuery] ADD CONSTRAINT [FK_LaborRatingScheduleQuery_LaborRatingTypeFID] FOREIGN KEY ([LaborRatingTypeFID]) REFERENCES [dbo].[LaborRatingType] ([LaborRatingTypeID])
GO
GRANT SELECT ON [dbo].[LaborRatingScheduleQuery] TO [MssExec]
GRANT INSERT ON [dbo].[LaborRatingScheduleQuery] TO [MssExec]
GRANT DELETE ON [dbo].[LaborRatingScheduleQuery] TO [MssExec]
GRANT UPDATE ON [dbo].[LaborRatingScheduleQuery] TO [MssExec]
GO