[dbo].[MilitaryAllocationItemCode]
CREATE TABLE [dbo].[MilitaryAllocationItemCode]
(
[MilitaryAllocationItemCodeID] [int] NOT NULL IDENTITY(1, 1),
[MilitaryAllocationHeaderFID] [int] NOT NULL,
[ItemCodeFID] [int] NOT NULL,
[Percentage] [float] NOT NULL,
[MinimumPayment] [money] NULL,
[EffectiveStart] [datetime] NULL,
[EffectiveEnd] [datetime] NULL,
[PayAgentFID] [int] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MilitaryAllocationItemCode] ADD CONSTRAINT [CK_MilitaryAllocationItemCode_ValidEffectiveDates] CHECK ((isnull([EffectiveStart],(0))<isnull([EffectiveEnd],(100000)) AND (1)=[dbo].[MilitaryAllocationItemCodeEffectiveDates]([MilitaryAllocationHeaderFID],[ItemCodeFID],[EffectiveStart],[EffectiveEnd])))
GO
ALTER TABLE [dbo].[MilitaryAllocationItemCode] ADD CONSTRAINT [PK_MilitaryAllocationItemCode] PRIMARY KEY CLUSTERED ([MilitaryAllocationItemCodeID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MilitaryAllocationItemCode] ADD CONSTRAINT [FK_MilitaryAllocationItemCode_ItemCode] FOREIGN KEY ([ItemCodeFID]) REFERENCES [dbo].[ItemCode] ([ICPriKey])
GO
ALTER TABLE [dbo].[MilitaryAllocationItemCode] ADD CONSTRAINT [FK_MilitaryAllocationItemCode_MilitaryAllocationHeader] FOREIGN KEY ([MilitaryAllocationHeaderFID]) REFERENCES [dbo].[MilitaryAllocationHeader] ([MilitaryAllocationHeaderID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[MilitaryAllocationItemCode] ADD CONSTRAINT [FK_MilitaryAllocationItemCode_PreferredRevenueAgent] FOREIGN KEY ([PayAgentFID]) REFERENCES [dbo].[PreferredRevenueAgent] ([PreferredRevenueAgentID])
GO
GRANT SELECT ON [dbo].[MilitaryAllocationItemCode] TO [MssExec]
GRANT INSERT ON [dbo].[MilitaryAllocationItemCode] TO [MssExec]
GRANT DELETE ON [dbo].[MilitaryAllocationItemCode] TO [MssExec]
GRANT UPDATE ON [dbo].[MilitaryAllocationItemCode] TO [MssExec]
GO