CREATE TABLE [dbo].[claim_variables_accounts]
(
[clacc_account_id] [int] NOT NULL,
[clacc_claim_id] [int] NOT NULL,
[clacc_variable_id] [int] NOT NULL,
[clacc_operation_code] [dbo].[ais_code_short] NOT NULL,
[clacc_user_code] [dbo].[ais_code_medium] NOT NULL,
[clacc_action] [smallint] NOT NULL CONSTRAINT [DF_claim_variables_accounts_clp_action] DEFAULT ((1)),
[clacc_obs] [nvarchar] (64) COLLATE French_CI_AS NULL,
[clacc_repr] [bit] NOT NULL CONSTRAINT [DF__claim_variables_accounts__clacc_repr] DEFAULT ((0)),
[clacc_injury] [bit] NOT NULL CONSTRAINT [DF__claim_variables_accounts__clacc_injury] DEFAULT ((0)),
[clacc_disable_accounting] [bit] NOT NULL CONSTRAINT [DF__claim_variables_accounts__clacc_disable_accounting] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[claim_variables_accounts] ADD CONSTRAINT [CK_claim_variables_accounts__clacc_action] CHECK (([clacc_action]=(2) OR [clacc_action]=(1) OR [clacc_action]=(0)))
GO
ALTER TABLE [dbo].[claim_variables_accounts] ADD CONSTRAINT [PK_claim_variables_accounts] PRIMARY KEY CLUSTERED  ([clacc_account_id]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[claim_variables_accounts] ADD CONSTRAINT [FK_claim_variables_accounts_acc_accounts] FOREIGN KEY ([clacc_account_id]) REFERENCES [dbo].[acc_accounts] ([a_account_id])
GO
ALTER TABLE [dbo].[claim_variables_accounts] ADD CONSTRAINT [FK_claim_variables_accounts_claim_variables] FOREIGN KEY ([clacc_claim_id], [clacc_variable_id]) REFERENCES [dbo].[claim_variables] ([clv_claim_id], [clv_variable_id])
GO
ALTER TABLE [dbo].[claim_variables_accounts] ADD CONSTRAINT [FK_claim_variables_accounts_nm_accounts_operations] FOREIGN KEY ([clacc_operation_code]) REFERENCES [dbo].[nm_accounts_operations] ([aco_operation_code])
GO
ALTER TABLE [dbo].[claim_variables_accounts] ADD CONSTRAINT [FK_claim_variables_accounts_usr_users] FOREIGN KEY ([clacc_user_code]) REFERENCES [dbo].[usr_users] ([usr_user_code])
GO
EXEC sp_addextendedproperty N'MS_Description', N'0 = set to 0, 1 = update, 2 = do not update', 'SCHEMA', N'dbo', 'TABLE', N'claim_variables_accounts', 'COLUMN', N'clacc_action'
GO
