CREATE TABLE [dbo].[pr_products_variables_taxes_cies]
(
[prdvtc_variable_id] [int] NOT NULL,
[prdvtc_tax_code] [dbo].[ais_code_short] NOT NULL,
[prdvtc_branch_id] [int] NOT NULL,
[prdvtc_company_id] [int] NOT NULL,
[prdvtc_payable_company] [bit] NOT NULL CONSTRAINT [DF__pr_products_variables_taxes_cies__prdvtc_payable_company] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[pr_products_variables_taxes_cies] ADD CONSTRAINT [PK_pr_products_variables_taxes_cies] PRIMARY KEY CLUSTERED  ([prdvtc_variable_id], [prdvtc_tax_code], [prdvtc_branch_id], [prdvtc_company_id]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[pr_products_variables_taxes_cies] ADD CONSTRAINT [FK_pr_products_variables_taxes_cies_act_cies] FOREIGN KEY ([prdvtc_company_id]) REFERENCES [dbo].[act_cies] ([cie_actor_id])
GO
ALTER TABLE [dbo].[pr_products_variables_taxes_cies] ADD CONSTRAINT [FK_pr_products_variables_taxes_cies_pr_products_variables_taxes] FOREIGN KEY ([prdvtc_variable_id], [prdvtc_tax_code], [prdvtc_branch_id]) REFERENCES [dbo].[pr_products_variables_taxes] ([prdvt_variable_id], [prdvt_tax_code], [prdvt_branch_id]) ON DELETE CASCADE
GO
