CREATE TABLE [dbo].[acc_invoices_operations]
(
[invop_invoice_id] [int] NOT NULL,
[invop_operation_utc_date] [datetime] NOT NULL,
[invop_operation_code] [dbo].[ais_code_short] NOT NULL,
[invop_user_code] [dbo].[ais_code_medium] NOT NULL,
[invop_obs] [nvarchar] (64) COLLATE French_CI_AS NULL,
[invop_branch_id] [int] NOT NULL,
[invop_department_code] [dbo].[ais_code_medium] NOT NULL
) ON [PRIMARY]
ALTER TABLE [dbo].[acc_invoices_operations] ADD 
CONSTRAINT [PK_acc_invoices_operations] PRIMARY KEY CLUSTERED  ([invop_invoice_id], [invop_operation_utc_date], [invop_operation_code]) ON [PRIMARY]

ALTER TABLE [dbo].[acc_invoices_operations] ADD
CONSTRAINT [FK_acc_invoices_operations_act_branches_departments] FOREIGN KEY ([invop_branch_id], [invop_department_code]) REFERENCES [dbo].[act_branches_departments] ([brdep_branch_id], [brdep_department_code])
ALTER TABLE [dbo].[acc_invoices_operations] ADD
CONSTRAINT [FK_acc_invoices_operations_acc_invoices1] FOREIGN KEY ([invop_invoice_id]) REFERENCES [dbo].[acc_invoices] ([inv_invoice_id])








GO

ALTER TABLE [dbo].[acc_invoices_operations] ADD CONSTRAINT [FK_acc_invoices_operations_nm_invoices_operations] FOREIGN KEY ([invop_operation_code]) REFERENCES [dbo].[nm_invoices_operations] ([op_operation_code])
GO
ALTER TABLE [dbo].[acc_invoices_operations] ADD CONSTRAINT [FK_acc_invoices_operations_usr_users] FOREIGN KEY ([invop_user_code]) REFERENCES [dbo].[usr_users] ([usr_user_code])
GO
