[dbo].[MilitaryAllocationDetailItem]
CREATE TABLE [dbo].[MilitaryAllocationDetailItem]
(
[MilitaryAllocationDetailItemID] [int] NOT NULL IDENTITY(1, 1),
[MilitaryAllocationDetailFID] [int] NOT NULL,
[PayAgentFID] [int] NOT NULL,
[CalculationTypeFID] [int] NOT NULL,
[ItemCodeFID] [int] NULL,
[Percentage] [float] NULL,
[Minimum] [float] NULL,
[ShareLevel] [float] NULL,
[ReductionTemplateRateLookupFID] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MilitaryAllocationDetailItem] ADD CONSTRAINT [CK_MilitaryAllocationDetailItem_ValidCalculationType] CHECK (((1)=[dbo].[CheckValidCalculationType]([CalculationTypeFID],[Percentage],[Minimum],[ShareLevel],[ReductionTemplateRateLookupFID])))
GO
ALTER TABLE [dbo].[MilitaryAllocationDetailItem] ADD CONSTRAINT [PK_MilitaryAllocationDetailItem] PRIMARY KEY CLUSTERED ([MilitaryAllocationDetailItemID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MilitaryAllocationDetailItem] ADD CONSTRAINT [FK_MilitaryAllocationDetailItem_CalculationType] FOREIGN KEY ([CalculationTypeFID]) REFERENCES [dbo].[AllocationCalculationType] ([AllocationCalculationTypeID])
GO
ALTER TABLE [dbo].[MilitaryAllocationDetailItem] ADD CONSTRAINT [FK_MilitaryAllocationDetailItem_ItemCode] FOREIGN KEY ([ItemCodeFID]) REFERENCES [dbo].[ItemCode] ([ICPriKey])
GO
ALTER TABLE [dbo].[MilitaryAllocationDetailItem] ADD CONSTRAINT [FK_MilitaryAllocationDetailItem_MilitaryAllocationDetail] FOREIGN KEY ([MilitaryAllocationDetailFID]) REFERENCES [dbo].[MilitaryAllocationDetail] ([MilitaryAllocationDetailID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[MilitaryAllocationDetailItem] ADD CONSTRAINT [FK_MilitaryAllocationDetailItem_PreferredRevenueAgent] FOREIGN KEY ([PayAgentFID]) REFERENCES [dbo].[PreferredRevenueAgent] ([PreferredRevenueAgentID])
GO
ALTER TABLE [dbo].[MilitaryAllocationDetailItem] ADD CONSTRAINT [FK_MilitaryAllocationDetailItem_ReductionTemplateRateLookup] FOREIGN KEY ([ReductionTemplateRateLookupFID]) REFERENCES [dbo].[ReductionTemplateRateLookup] ([ReductionTemplateRateLookupID])
GO
GRANT SELECT ON [dbo].[MilitaryAllocationDetailItem] TO [MssExec]
GRANT INSERT ON [dbo].[MilitaryAllocationDetailItem] TO [MssExec]
GRANT DELETE ON [dbo].[MilitaryAllocationDetailItem] TO [MssExec]
GRANT UPDATE ON [dbo].[MilitaryAllocationDetailItem] TO [MssExec]
GO