[dbo].[DocumentAutoDownloadRuleDetailBranch]
CREATE TABLE [dbo].[DocumentAutoDownloadRuleDetailBranch]
(
[DocumentAutoDownloadRuleDetailBranchID] [int] NOT NULL IDENTITY(1, 1),
[DocumentAutoDownloadRuleDetailFID] [int] NOT NULL,
[BranchFID] [int] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[DocumentAutoDownloadRuleDetailBranch] ADD CONSTRAINT [PK_DocumentAutoDownloadRuleDetailBranch] PRIMARY KEY CLUSTERED ([DocumentAutoDownloadRuleDetailBranchID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_DocumentAutoDownloadRuleDetailBranch_Branch] ON [dbo].[DocumentAutoDownloadRuleDetailBranch] ([BranchFID]) ON [PRIMARY]
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_DocumentAutoDownloadRuleDetailBranch_RuleDetail] ON [dbo].[DocumentAutoDownloadRuleDetailBranch] ([DocumentAutoDownloadRuleDetailFID], [BranchFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[DocumentAutoDownloadRuleDetailBranch] ADD CONSTRAINT [FK_DocumentAutoDownloadRuleDetailBranch_Branch] FOREIGN KEY ([BranchFID]) REFERENCES [dbo].[Branch] ([BranchPriKey]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[DocumentAutoDownloadRuleDetailBranch] ADD CONSTRAINT [FK_DocumentAutoDownloadRuleDetailBranch_DocumentAutoDownloadRuleDetail] FOREIGN KEY ([DocumentAutoDownloadRuleDetailFID]) REFERENCES [dbo].[DocumentAutoDownloadRuleDetail] ([DocumentAutoDownloadRuleDetailID]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[DocumentAutoDownloadRuleDetailBranch] TO [MssExec]
GRANT INSERT ON [dbo].[DocumentAutoDownloadRuleDetailBranch] TO [MssExec]
GRANT DELETE ON [dbo].[DocumentAutoDownloadRuleDetailBranch] TO [MssExec]
GRANT UPDATE ON [dbo].[DocumentAutoDownloadRuleDetailBranch] TO [MssExec]
GO