[dbo].[OrderStatusFieldRequirement]
CREATE TABLE [dbo].[OrderStatusFieldRequirement]
(
[OrderStatusFieldRequirementID] [int] NOT NULL IDENTITY(1, 1),
[OrderStatusFieldRequirementMasterFID] [int] NOT NULL,
[OrderStatusFID] [int] NOT NULL,
[ShipmentTypeFID] [int] NULL,
[RequireableFieldFID] [int] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OrderStatusFieldRequirement] ADD CONSTRAINT [PK_OrderStatusFieldRequirement] PRIMARY KEY NONCLUSTERED ([OrderStatusFieldRequirementID]) ON [PRIMARY]
GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_OrderStatusFieldRequirement_OrderStatusFID_ShipmentTypeFID_RequireableFieldFID] ON [dbo].[OrderStatusFieldRequirement] ([OrderStatusFID], [ShipmentTypeFID], [RequireableFieldFID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[OrderStatusFieldRequirement] ADD CONSTRAINT [FK_OrderStatusFieldRequirement_OrderStatus] FOREIGN KEY ([OrderStatusFID]) REFERENCES [dbo].[OrderStatus] ([PriKey])
GO
ALTER TABLE [dbo].[OrderStatusFieldRequirement] ADD CONSTRAINT [FK_OrderStatusFieldRequirement_OrderStatusFieldRequirementMaster] FOREIGN KEY ([OrderStatusFieldRequirementMasterFID]) REFERENCES [dbo].[OrderStatusFieldRequirementMaster] ([OrderStatusFieldRequirementMasterID])
GO
ALTER TABLE [dbo].[OrderStatusFieldRequirement] ADD CONSTRAINT [FK_OrderStatusFieldRequirement_RequireableField] FOREIGN KEY ([RequireableFieldFID]) REFERENCES [dbo].[RequireableField] ([RequireableFieldID])
GO
ALTER TABLE [dbo].[OrderStatusFieldRequirement] ADD CONSTRAINT [FK_OrderStatusFieldRequirement_ShipmentType] FOREIGN KEY ([ShipmentTypeFID]) REFERENCES [dbo].[ShipmentType] ([ShipmentTypeID])
GO
GRANT SELECT ON [dbo].[OrderStatusFieldRequirement] TO [MssExec]
GRANT INSERT ON [dbo].[OrderStatusFieldRequirement] TO [MssExec]
GRANT DELETE ON [dbo].[OrderStatusFieldRequirement] TO [MssExec]
GRANT UPDATE ON [dbo].[OrderStatusFieldRequirement] TO [MssExec]
GO