CREATE TABLE [dbo].[AgentMarket]
(
[AgentMarketID] [int] NOT NULL IDENTITY(1, 1),
[AgentFID] [int] NOT NULL,
[MarketFID] [int] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AgentMarket] ADD CONSTRAINT [PK_AgentMarket] PRIMARY KEY CLUSTERED ([AgentMarketID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AgentMarket] ADD CONSTRAINT [IX_AgentMarket_Agent_Market] UNIQUE NONCLUSTERED ([AgentFID], [MarketFID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_AgentMarket_AgentFID] ON [dbo].[AgentMarket] ([AgentFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AgentMarket] ADD CONSTRAINT [FK_AgentMarket_Agent] FOREIGN KEY ([AgentFID]) REFERENCES [dbo].[Agent] ([AgentPriKey])
GO
ALTER TABLE [dbo].[AgentMarket] ADD CONSTRAINT [FK_AgentMarket_Market] FOREIGN KEY ([MarketFID]) REFERENCES [dbo].[Market] ([MarketID])
GO
GRANT SELECT ON [dbo].[AgentMarket] TO [MssExec]
GRANT INSERT ON [dbo].[AgentMarket] TO [MssExec]
GRANT DELETE ON [dbo].[AgentMarket] TO [MssExec]
GRANT UPDATE ON [dbo].[AgentMarket] TO [MssExec]
GO