CREATE TABLE [dbo].[ItemCodeAgentPct]
(
[ItemCodeAgentPctID] [int] NOT NULL IDENTITY(1, 1),
[ItemCodeFID] [int] NOT NULL,
[AuthorityTypeFID] [int] NOT NULL,
[AgentPercentage] [float] NOT NULL,
[ShipmentTypeFID] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ItemCodeAgentPct] ADD CONSTRAINT [PK_ItemCodeAgentPct] PRIMARY KEY NONCLUSTERED ([ItemCodeAgentPctID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ItemCodeAgentPct] ADD CONSTRAINT [IX_ItemCodeAgentPct] UNIQUE CLUSTERED ([ItemCodeFID], [AuthorityTypeFID], [ShipmentTypeFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ItemCodeAgentPct] ADD CONSTRAINT [FK_ItemCodeAgentPct_AuthorityTypes] FOREIGN KEY ([AuthorityTypeFID]) REFERENCES [dbo].[AuthorityTypes] ([AuthPriKey])
GO
ALTER TABLE [dbo].[ItemCodeAgentPct] ADD CONSTRAINT [FK_ItemCodeAgentPct_ItemCode] FOREIGN KEY ([ItemCodeFID]) REFERENCES [dbo].[ItemCode] ([ICPriKey])
GO
ALTER TABLE [dbo].[ItemCodeAgentPct] ADD CONSTRAINT [FK_ItemCodeAgentPct_ShipmentType] FOREIGN KEY ([ShipmentTypeFID]) REFERENCES [dbo].[ShipmentType] ([ShipmentTypeID])
GO
GRANT SELECT ON [dbo].[ItemCodeAgentPct] TO [MssExec]
GRANT INSERT ON [dbo].[ItemCodeAgentPct] TO [MssExec]
GRANT DELETE ON [dbo].[ItemCodeAgentPct] TO [MssExec]
GRANT UPDATE ON [dbo].[ItemCodeAgentPct] TO [MssExec]
GO