CREATE TABLE [dbo].[XmlUserMap]
(
[XmlUserMapID] [int] NOT NULL IDENTITY(1, 1),
[XmlInterfaceFID] [int] NOT NULL,
[SysUserFID] [int] NOT NULL,
[UserID] [varchar] (256) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[LaborTypeFID] [int] NOT NULL,
[BranchFID] [int] NULL,
[IsNoBranchDefault] [bit] NOT NULL CONSTRAINT [DF_XmlUserMap_IsNoBranchDefault] DEFAULT ((1))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlUserMap] ADD CONSTRAINT [PK_XmlUserMap] PRIMARY KEY NONCLUSTERED ([XmlUserMapID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlUserMap] ADD CONSTRAINT [IX_XmlUserMap_SysUserFID_XmlInterfaceFID_LaborTypeFID_BranchFID] UNIQUE NONCLUSTERED ([SysUserFID], [XmlInterfaceFID], [LaborTypeFID], [BranchFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlUserMap] ADD CONSTRAINT [IX_XmlUserMap_SysUserFID_XmlInterfaceFID_LaborTypeFID_BranchFID_UserID] UNIQUE NONCLUSTERED ([SysUserFID], [XmlInterfaceFID], [LaborTypeFID], [BranchFID], [UserID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlUserMap] ADD CONSTRAINT [IX_XmlUserMap_XmlInterfaceFID_UserID_LaborTypeFID] UNIQUE NONCLUSTERED ([XmlInterfaceFID], [UserID], [LaborTypeFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlUserMap] ADD CONSTRAINT [IX_XmlUserMap_XmlInterfaceFID_UserID_LaborTypeFID_BranchFID_SysUserFID] UNIQUE NONCLUSTERED ([XmlInterfaceFID], [UserID], [LaborTypeFID], [BranchFID], [SysUserFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlUserMap] ADD CONSTRAINT [FK_XmlUserMap_Branch] FOREIGN KEY ([BranchFID]) REFERENCES [dbo].[Branch] ([BranchPriKey])
GO
ALTER TABLE [dbo].[XmlUserMap] ADD CONSTRAINT [FK_XmlUserMap_LaborType] FOREIGN KEY ([LaborTypeFID]) REFERENCES [dbo].[LaborType] ([PriKey])
GO
ALTER TABLE [dbo].[XmlUserMap] ADD CONSTRAINT [FK_XmlUserMap_SysUser] FOREIGN KEY ([SysUserFID]) REFERENCES [dbo].[Sysuser] ([SysUserID])
GO
ALTER TABLE [dbo].[XmlUserMap] ADD CONSTRAINT [FK_XmlUserMap_XmlInterface] FOREIGN KEY ([XmlInterfaceFID]) REFERENCES [dbo].[XmlInterface] ([XmlInterfaceID])
GO
GRANT SELECT ON [dbo].[XmlUserMap] TO [MssExec]
GRANT INSERT ON [dbo].[XmlUserMap] TO [MssExec]
GRANT DELETE ON [dbo].[XmlUserMap] TO [MssExec]
GRANT UPDATE ON [dbo].[XmlUserMap] TO [MssExec]
GO