CREATE TABLE [dbo].[acc_invoices_risks_variables_taxes_cies]
(
[invrisvtc_invoice_id] [int] NOT NULL,
[invrisvtc_risk_situation_id] [int] NOT NULL,
[invrisvtc_variable_id] [int] NOT NULL,
[invrisvtc_tax_id] [int] NOT NULL,
[invrisvtc_company_id] [int] NOT NULL,
[invrisvtc_tax_value] [dbo].[ais_decimal2] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[acc_invoices_risks_variables_taxes_cies] ADD CONSTRAINT [PK_acc_invoices_risks_variables_taxes_cies] PRIMARY KEY CLUSTERED  ([invrisvtc_invoice_id], [invrisvtc_risk_situation_id], [invrisvtc_variable_id], [invrisvtc_tax_id], [invrisvtc_company_id]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[acc_invoices_risks_variables_taxes_cies] ADD CONSTRAINT [FK_acc_invoices_risks_variables_taxes_cies_acc_invoices_risks_variables_taxes] FOREIGN KEY ([invrisvtc_invoice_id], [invrisvtc_risk_situation_id], [invrisvtc_variable_id], [invrisvtc_tax_id]) REFERENCES [dbo].[acc_invoices_risks_variables_taxes] ([invrisvt_invoice_id], [invrisvt_risk_situation_id], [invrisvt_variable_id], [invrisvt_tax_id])
GO
ALTER TABLE [dbo].[acc_invoices_risks_variables_taxes_cies] ADD CONSTRAINT [FK_acc_invoices_risks_variables_taxes_cies_act_cies] FOREIGN KEY ([invrisvtc_company_id]) REFERENCES [dbo].[act_cies] ([cie_actor_id])
GO
