[dbo].[SysUserLaborTypeCPMaster]
CREATE TABLE [dbo].[SysUserLaborTypeCPMaster]
(
[SysUserLaborTypeCPMasterID] [int] NOT NULL IDENTITY(1, 1),
[SysUserLaborTypeMapFID] [int] NOT NULL,
[CPMasterFID] [int] NOT NULL,
[EffectiveStartDate] [date] NULL,
[EffectiveEndDate] [date] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[SysUserLaborTypeCPMaster] ADD CONSTRAINT [CK_SysUserLaborTypeCPMaster_DateRange] CHECK ((NOT ([EffectiveStartDate] IS NOT NULL AND [EffectiveEndDate] IS NOT NULL AND [EffectiveStartDate]>[EffectiveEndDate])))
GO
ALTER TABLE [dbo].[SysUserLaborTypeCPMaster] ADD CONSTRAINT [CK_SysUserLaborTypeCPMaster_SysUser_DateRange] CHECK (((1)=[dbo].[IsCommissionPlanMasterDateRangeUnique]([SysUserLaborTypeMapFID],[EffectiveStartDate],[EffectiveEndDate])))
GO
ALTER TABLE [dbo].[SysUserLaborTypeCPMaster] ADD CONSTRAINT [PK_SysUserLaborTypeCPMaster] PRIMARY KEY CLUSTERED ([SysUserLaborTypeCPMasterID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_SysUserLaborTypeCPMaster_SysUserLaborTypeMapFID_CPMasterFID_EffectiveStartDate_EffectiveEndDate] ON [dbo].[SysUserLaborTypeCPMaster] ([SysUserLaborTypeMapFID], [CPMasterFID], [EffectiveStartDate] DESC, [EffectiveEndDate] DESC) ON [PRIMARY]
GO
ALTER TABLE [dbo].[SysUserLaborTypeCPMaster] ADD CONSTRAINT [FK_SysUserLaborTypeCPMaster_CPMaster] FOREIGN KEY ([CPMasterFID]) REFERENCES [dbo].[CPMaster] ([CPPriKey])
GO
ALTER TABLE [dbo].[SysUserLaborTypeCPMaster] ADD CONSTRAINT [FK_SysUserLaborTypeCPMaster_SysUserLaborTypeMap] FOREIGN KEY ([SysUserLaborTypeMapFID]) REFERENCES [dbo].[SysUserLaborTypeMap] ([SysUserLaborTypeMapID])
GO
GRANT SELECT ON [dbo].[SysUserLaborTypeCPMaster] TO [MssExec]
GRANT INSERT ON [dbo].[SysUserLaborTypeCPMaster] TO [MssExec]
GRANT DELETE ON [dbo].[SysUserLaborTypeCPMaster] TO [MssExec]
GRANT UPDATE ON [dbo].[SysUserLaborTypeCPMaster] TO [MssExec]
GO