[dbo].[XmlInterfaceBranch]
CREATE TABLE [dbo].[XmlInterfaceBranch]
(
[XmlInterfaceBranchID] [int] NOT NULL IDENTITY(1, 1),
[XmlInterfaceFID] [int] NOT NULL,
[BranchFID] [int] NOT NULL,
[AuthorityFID] [int] NOT NULL,
[ExternalCode] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlInterfaceBranch] ADD CONSTRAINT [PK_XmlInterfaceBranch] PRIMARY KEY CLUSTERED ([XmlInterfaceBranchID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlInterfaceBranch] ADD CONSTRAINT [IX_XmlInterface_Branch] UNIQUE NONCLUSTERED ([XmlInterfaceFID], [BranchFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlInterfaceBranch] ADD CONSTRAINT [IX_XmlInterface_Branch_ExternalCode] UNIQUE NONCLUSTERED ([XmlInterfaceFID], [BranchFID], [ExternalCode]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_XmlInterfaceBranch_Interface_Branch] ON [dbo].[XmlInterfaceBranch] ([XmlInterfaceFID], [BranchFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_XmlInterfaceBranch_Interface_ExternalCode] ON [dbo].[XmlInterfaceBranch] ([XmlInterfaceFID], [ExternalCode]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[XmlInterfaceBranch] ADD CONSTRAINT [FK_XmlInterfaceBranch_AuthorityType] FOREIGN KEY ([AuthorityFID]) REFERENCES [dbo].[AuthorityTypes] ([AuthPriKey])
GO
ALTER TABLE [dbo].[XmlInterfaceBranch] ADD CONSTRAINT [FK_XmlInterfaceBranch_Branch] FOREIGN KEY ([BranchFID]) REFERENCES [dbo].[Branch] ([BranchPriKey])
GO
ALTER TABLE [dbo].[XmlInterfaceBranch] ADD CONSTRAINT [FK_XmlInterfaceBranch_XmlInterface] FOREIGN KEY ([XmlInterfaceFID]) REFERENCES [dbo].[XmlInterface] ([XmlInterfaceID]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[XmlInterfaceBranch] TO [MssExec]
GRANT INSERT ON [dbo].[XmlInterfaceBranch] TO [MssExec]
GRANT DELETE ON [dbo].[XmlInterfaceBranch] TO [MssExec]
GRANT UPDATE ON [dbo].[XmlInterfaceBranch] TO [MssExec]
GO
EXEC sp_addextendedproperty N'MS_Description', N'The primary key.', 'SCHEMA', N'dbo', 'TABLE', N'XmlInterfaceBranch', 'COLUMN', N'XmlInterfaceBranchID'
GO