[dbo].[PlasticOriginMapping]
CREATE TABLE [dbo].[PlasticOriginMapping]
(
[OriginMappingID] [int] NOT NULL IDENTITY(1, 1),
[OriginFID] [int] NOT NULL,
[ProviderTypeFID] [int] NOT NULL,
[ExternalCode] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[PlasticOriginMapping] ADD CONSTRAINT [PK_PlasticOriginMapping] PRIMARY KEY NONCLUSTERED ([OriginMappingID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[PlasticOriginMapping] ADD CONSTRAINT [IX_PlasticOriginMapping_Origin_Provider] UNIQUE CLUSTERED ([OriginFID], [ProviderTypeFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[PlasticOriginMapping] ADD CONSTRAINT [IX_PlasticOriginMapping_ExternalCode] UNIQUE NONCLUSTERED ([ProviderTypeFID], [ExternalCode]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[PlasticOriginMapping] ADD CONSTRAINT [FK_PlasticOriginMapping_OriginFID] FOREIGN KEY ([OriginFID]) REFERENCES [dbo].[PlasticOrigin] ([OriginID])
GO
ALTER TABLE [dbo].[PlasticOriginMapping] ADD CONSTRAINT [FK_PlasticOriginMapping_ProviderTypeFID] FOREIGN KEY ([ProviderTypeFID]) REFERENCES [dbo].[PlasticProviderType] ([ProviderTypeID])
GO
GRANT SELECT ON [dbo].[PlasticOriginMapping] TO [MssExec]
GRANT INSERT ON [dbo].[PlasticOriginMapping] TO [MssExec]
GRANT DELETE ON [dbo].[PlasticOriginMapping] TO [MssExec]
GRANT UPDATE ON [dbo].[PlasticOriginMapping] TO [MssExec]
GO