CREATE TABLE [dbo].[nm_types_retro]
(
[nmtr_type_retro_code] [dbo].[ais_code_medium] NOT NULL,
[nmtr_l1] [nvarchar] (128) COLLATE French_CI_AS NOT NULL,
[nmtr_l2] [nvarchar] (128) COLLATE French_CI_AS NULL,
[nmtr_l3] [nvarchar] (128) COLLATE French_CI_AS NULL,
[nmtr_sys] [bit] NOT NULL CONSTRAINT [DF__nm_types_retro__nmtr_sys] DEFAULT ((0)),
[nmtr_peril_base_amount_code] [dbo].[ais_code_medium] NULL,
[nmtr_broker_cost_base_amount_code] [dbo].[ais_code_medium] NULL,
[nmtr_broker_fee_base_amount_code] [dbo].[ais_code_medium] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[nm_types_retro] ADD CONSTRAINT [CK__nm_types_retro_nmtr_type_retro_code__string_pk] CHECK ((len(ltrim(rtrim([nmtr_type_retro_code])))>(0) AND charindex('*',[nmtr_type_retro_code])=(0) AND charindex('%',[nmtr_type_retro_code])=(0)))
GO
ALTER TABLE [dbo].[nm_types_retro] WITH NOCHECK ADD CONSTRAINT [CK_nm_types_retro_base_amount_required_input] CHECK (([nmtr_peril_base_amount_code] IS NOT NULL OR [nmtr_broker_cost_base_amount_code] IS NOT NULL OR [nmtr_broker_fee_base_amount_code] IS NOT NULL))
GO
ALTER TABLE [dbo].[nm_types_retro] ADD CONSTRAINT [PK_nm_types_retro] PRIMARY KEY CLUSTERED  ([nmtr_type_retro_code]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[nm_types_retro] ADD CONSTRAINT [FK_nm_types_retro_nm_types_retro_base_amount] FOREIGN KEY ([nmtr_broker_cost_base_amount_code]) REFERENCES [dbo].[nm_types_retro_base_amount] ([nmtrba_base_amount_code])
GO
ALTER TABLE [dbo].[nm_types_retro] ADD CONSTRAINT [FK_nm_types_retro_nm_types_retro_base_amount1] FOREIGN KEY ([nmtr_broker_fee_base_amount_code]) REFERENCES [dbo].[nm_types_retro_base_amount] ([nmtrba_base_amount_code])
GO
ALTER TABLE [dbo].[nm_types_retro] ADD CONSTRAINT [FK_nm_types_retro_nm_types_retro_base_amount2] FOREIGN KEY ([nmtr_peril_base_amount_code]) REFERENCES [dbo].[nm_types_retro_base_amount] ([nmtrba_base_amount_code])
GO
