[dbo].[DocumentAutoDownloadRuleDetail]
CREATE TABLE [dbo].[DocumentAutoDownloadRuleDetail]
(
[DocumentAutoDownloadRuleDetailID] [int] NOT NULL IDENTITY(1, 1),
[DocumentAutoDownloadRuleFID] [int] NOT NULL,
[DocumentAutoDownloadRuleItemFID] [int] NOT NULL,
[SortOrder] [int] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[DocumentAutoDownloadRuleDetail] ADD CONSTRAINT [PK_DocumentAutoDownloadRuleDetail] PRIMARY KEY CLUSTERED ([DocumentAutoDownloadRuleDetailID]) ON [PRIMARY]
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_DocumentAutoDownloadRuleDetail_Rule] ON [dbo].[DocumentAutoDownloadRuleDetail] ([DocumentAutoDownloadRuleFID], [SortOrder]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_DocumentAutoDownloadRuleDetail_Item] ON [dbo].[DocumentAutoDownloadRuleDetail] ([DocumentAutoDownloadRuleItemFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[DocumentAutoDownloadRuleDetail] ADD CONSTRAINT [FK_DocumentAutoDownloadRuleDetail_DocumentAutoDownloadRule] FOREIGN KEY ([DocumentAutoDownloadRuleFID]) REFERENCES [dbo].[DocumentAutoDownloadRule] ([DocumentAutoDownloadRuleID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[DocumentAutoDownloadRuleDetail] ADD CONSTRAINT [FK_DocumentAutoDownloadRuleDetail_DocumentAutoDownloadRuleItem] FOREIGN KEY ([DocumentAutoDownloadRuleItemFID]) REFERENCES [dbo].[DocumentAutoDownloadRuleItem] ([DocumentAutoDownloadRuleItemID]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[DocumentAutoDownloadRuleDetail] TO [MssExec]
GRANT INSERT ON [dbo].[DocumentAutoDownloadRuleDetail] TO [MssExec]
GRANT DELETE ON [dbo].[DocumentAutoDownloadRuleDetail] TO [MssExec]
GRANT UPDATE ON [dbo].[DocumentAutoDownloadRuleDetail] TO [MssExec]
GO