CREATE TABLE [dbo].[LSCrewTimes]
(
[PriKey] [int] NOT NULL IDENTITY(1, 1),
[LSCPriKey] [int] NOT NULL,
[StartTime] [datetime] NOT NULL,
[EndTime] [datetime] NOT NULL,
[OverTime] [bit] NOT NULL CONSTRAINT [DF_LSCrewTimes_OverTime] DEFAULT ((0)),
[ActualCreatedBy] [int] NULL,
[MobileCrewTimeActivityFID] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[LSCrewTimes] ADD CONSTRAINT [PK_LSCrewTimes] PRIMARY KEY NONCLUSTERED ([PriKey]) ON [PRIMARY]
GO
CREATE CLUSTERED INDEX [IX_LSCrewTimes_LSCPriKey_StartTime] ON [dbo].[LSCrewTimes] ([LSCPriKey], [StartTime]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_LSCrewTimes_StartTime] ON [dbo].[LSCrewTimes] ([StartTime]) INCLUDE ([EndTime]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[LSCrewTimes] ADD CONSTRAINT [FK_LSCrewTimes_Sysuser] FOREIGN KEY ([ActualCreatedBy]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[LSCrewTimes] ADD CONSTRAINT [FK_LSCrewTimes_LSCrew] FOREIGN KEY ([LSCPriKey]) REFERENCES [dbo].[LSCrew] ([PriKey])
GO
ALTER TABLE [dbo].[LSCrewTimes] ADD CONSTRAINT [FK_LSCrewTimes_MobileCrewActivity] FOREIGN KEY ([MobileCrewTimeActivityFID]) REFERENCES [dbo].[MobileCrewTimeActivity] ([MobileCrewTimeActivityID])
GO
GRANT SELECT ON [dbo].[LSCrewTimes] TO [MssExec]
GRANT INSERT ON [dbo].[LSCrewTimes] TO [MssExec]
GRANT DELETE ON [dbo].[LSCrewTimes] TO [MssExec]
GRANT UPDATE ON [dbo].[LSCrewTimes] TO [MssExec]
GO