CREATE TABLE [MS].[Pourbacks] ( [PourbackId] INT IDENTITY (1, 1) NOT NULL, [HeatId] INT NULL, -- Heat Id can be null only for pourback coming form unlinked caster processes [SourceProcessId] INT NOT NULL, --process (typically on Caster) where the Pourback is generated [SourceTime] DATETIME NOT NULL, --when Pourback is declared at Caster [PourbackWeight] FLOAT NULL, -- remaining steel on ladle poured back. [PourbackReasonId] INT NOT NULL, -- FK table catPourbackReasons [DestinationProcessId] INT NULL, --process (typically on EAF) where the Pourback is charged [ChargedTime] DATETIME NULL -- when Pourback is charged at EAF [ChargedWeight] FLOAT NULL, -- charge weith declared at EAF [IsActive] BIT NOT NULL DEFAULT((1)), CONSTRAINT [PK_MS.Pourbacks] PRIMARY KEY CLUSTERED ([PourbackId] ASC), CONSTRAINT [FK_MS.Processes_MS.Heats] FOREIGN KEY ([HeatId]) REFERENCES [MS].[Heats] ([HeatId]), CONSTRAINT [FK_MS.Pourbacks_MS.Processes] FOREIGN KEY ([SourceProcessId]) REFERENCES [MS].[Processes] ([ProcessId]), CONSTRAINT [FK_MS.Pourbacks_MS.Processes] FOREIGN KEY ([DestinationProcessId]) REFERENCES [MS].[Processes] ([ProcessId]), CONSTRAINT [FK_MS.Pourbacks_MS.catPourbackReasons] FOREIGN KEY ([PourbackReasonId]) REFERENCES [MS].[catPourbackReasons] ([PourbackReasonId]) );