CREATE TABLE [dbo].[RateMatrixRate]
(
[RateMatrixRateID] [int] NOT NULL IDENTITY(1, 1),
[RateMatrixRangeXFID] [int] NOT NULL,
[RateMatrixRangeYFID] [int] NOT NULL,
[Rate] [decimal] (12, 2) NOT NULL,
[BreakpointX] [decimal] (12, 3) NULL,
[BreakpointY] [decimal] (12, 3) NULL,
[ForeignID] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[RateMatrixRate] ADD CONSTRAINT [CK_RateMatrixRate_ValidBreakpoints] CHECK (((1)=[dbo].[RateMatrixRateValidRanges]([RateMatrixRangeXFID],[BreakpointX],[RateMatrixRangeYFID],[BreakpointY])))
GO
ALTER TABLE [dbo].[RateMatrixRate] ADD CONSTRAINT [PK_RateMatrixRate] PRIMARY KEY CLUSTERED ([RateMatrixRateID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[RateMatrixRate] ADD CONSTRAINT [IX_RateMatrixRate_RateMatrixXY] UNIQUE NONCLUSTERED ([RateMatrixRangeXFID], [RateMatrixRangeYFID]) WITH (FILLFACTOR=80) ON [PRIMARY]
GO
ALTER TABLE [dbo].[RateMatrixRate] ADD CONSTRAINT [FK_RateMatrixRate_RateMatrixRangeX] FOREIGN KEY ([RateMatrixRangeXFID]) REFERENCES [dbo].[RateMatrixRangeX] ([RateMatrixRangeXID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[RateMatrixRate] ADD CONSTRAINT [FK_RateMatrixRate_RateMatrixRangeY] FOREIGN KEY ([RateMatrixRangeYFID]) REFERENCES [dbo].[RateMatrixRangeY] ([RateMatrixRangeYID]) ON DELETE CASCADE
GO
GRANT SELECT ON [dbo].[RateMatrixRate] TO [MssExec]
GRANT INSERT ON [dbo].[RateMatrixRate] TO [MssExec]
GRANT DELETE ON [dbo].[RateMatrixRate] TO [MssExec]
GRANT UPDATE ON [dbo].[RateMatrixRate] TO [MssExec]
GO