[dbo].[InvoiceRequirement]
CREATE TABLE [dbo].[InvoiceRequirement]
(
[InvoiceRequirementID] [int] NOT NULL IDENTITY(1, 1),
[CustomerNumber] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[AuthorityTypeFID] [int] NOT NULL,
[BranchFID] [int] NOT NULL,
[InvoiceRequirementTypeFID] [int] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[InvoiceRequirement] ADD CONSTRAINT [PK_InvoiceRequirement] PRIMARY KEY NONCLUSTERED ([InvoiceRequirementID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[InvoiceRequirement] ADD CONSTRAINT [IX_InvoiceRequirement_Customer_Authority_Branch] UNIQUE NONCLUSTERED ([CustomerNumber], [AuthorityTypeFID], [BranchFID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_InvoiceRequirement_AuthorityType] ON [dbo].[InvoiceRequirement] ([AuthorityTypeFID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_InvoiceRequirement_Branch] ON [dbo].[InvoiceRequirement] ([BranchFID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
CREATE CLUSTERED INDEX [IX_InvoiceRequirement_Customer] ON [dbo].[InvoiceRequirement] ([CustomerNumber]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[InvoiceRequirement] ADD CONSTRAINT [FK_InvoiceRequirement_AuthorityTypes] FOREIGN KEY ([AuthorityTypeFID]) REFERENCES [dbo].[AuthorityTypes] ([AuthPriKey])
GO
ALTER TABLE [dbo].[InvoiceRequirement] ADD CONSTRAINT [FK_InvoiceRequirement_Branch] FOREIGN KEY ([BranchFID]) REFERENCES [dbo].[Branch] ([BranchPriKey])
GO
ALTER TABLE [dbo].[InvoiceRequirement] ADD CONSTRAINT [FK_InvoiceRequirement_InvoiceRequirementType] FOREIGN KEY ([InvoiceRequirementTypeFID]) REFERENCES [dbo].[InvoiceRequirementType] ([InvoiceRequirementTypeID])
GO
GRANT SELECT ON [dbo].[InvoiceRequirement] TO [MssExec]
GRANT INSERT ON [dbo].[InvoiceRequirement] TO [MssExec]
GRANT DELETE ON [dbo].[InvoiceRequirement] TO [MssExec]
GRANT UPDATE ON [dbo].[InvoiceRequirement] TO [MssExec]
GO