CREATE TABLE [dbo].[POReceiptDetailShipmentLinks]
(
[ReceiptDetailShipmentLinkID] [int] NOT NULL IDENTITY(1, 1),
[ReceiptID] [int] NOT NULL,
[ReceiptDetailID] [int] NOT NULL,
[POShipmentDetailID] [int] NOT NULL,
[POShipmentDetailBinID] [int] NULL,
[QuantityReceived] [decimal] (18, 6) NOT NULL,
[CreateDate] [datetime] NOT NULL CONSTRAINT [DF_POReceiptDetailShipmentLinks_CreateDate] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[POReceiptDetailShipmentLinks] ADD CONSTRAINT [PK_POReceiptDetailShipmentLinks] PRIMARY KEY CLUSTERED ([ReceiptDetailShipmentLinkID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[POReceiptDetailShipmentLinks] ADD CONSTRAINT [FK_POReceiptDetailShipmentLinks_POShipmentDetailBinID_POShipmentDetailBins] FOREIGN KEY ([POShipmentDetailBinID]) REFERENCES [dbo].[POShipmentDetailBins] ([POShipmentDetailBinID])
GO
ALTER TABLE [dbo].[POReceiptDetailShipmentLinks] ADD CONSTRAINT [FK_POReceiptDetailShipmentLinks_POShipmentDetailID_POShipmentDetails] FOREIGN KEY ([POShipmentDetailID]) REFERENCES [dbo].[POShipmentDetails] ([POShipmentDetailID])
GO
ALTER TABLE [dbo].[POReceiptDetailShipmentLinks] ADD CONSTRAINT [FK_POReceiptDetailShipmentLinks_ReceiptID_POReceiptDetails] FOREIGN KEY ([ReceiptID], [ReceiptDetailID]) REFERENCES [dbo].[POReceiptDetails] ([ReceiptID], [DetailID])
GO