CREATE TABLE [dbo].[acc_transactions]
(
[atrn_transaction_id] [int] NOT NULL,
[atrn_payment_code] [dbo].[ais_code_short] NOT NULL,
[atrn_obs] [nvarchar] (64) COLLATE French_CI_AS NULL,
[atrn_reference] [varchar] (50) COLLATE French_CI_AS NULL,
[atrn_holder] [varchar] (50) COLLATE French_CI_AS NULL,
[atrn_holder_bank] [varchar] (50) COLLATE French_CI_AS NULL,
[atrn_branch_id] [int] NOT NULL,
[atrn_account_number__branch] [varchar] (50) COLLATE French_CI_AS NULL,
[atrn_actor_id] [int] NOT NULL,
[atrn_account_number__actor] [varchar] (50) COLLATE French_CI_AS NULL,
[atrn_department_code] [dbo].[ais_code_medium] NOT NULL,
[atrn_user_code] [dbo].[ais_code_medium] NOT NULL,
[atrn_check_out_of_town] [bit] NOT NULL CONSTRAINT [DF__acc_transactions__atrn_check_out_of_town] DEFAULT ((0)),
[atrn_type_code] [dbo].[ais_code_short] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[acc_transactions] ADD CONSTRAINT [PK_acc_transactions] PRIMARY KEY CLUSTERED  ([atrn_transaction_id]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[acc_transactions] ADD CONSTRAINT [FK_acc_transactions_acc_accounts] FOREIGN KEY ([atrn_transaction_id]) REFERENCES [dbo].[acc_accounts] ([a_account_id])
GO
ALTER TABLE [dbo].[acc_transactions] ADD CONSTRAINT [FK_acc_transactions_act_accounts] FOREIGN KEY ([atrn_branch_id], [atrn_account_number__branch]) REFERENCES [dbo].[act_accounts] ([acc_actor_id], [acc_account_number])
GO
ALTER TABLE [dbo].[acc_transactions] ADD CONSTRAINT [FK_acc_transactions_act_accounts1] FOREIGN KEY ([atrn_actor_id], [atrn_account_number__actor]) REFERENCES [dbo].[act_accounts] ([acc_actor_id], [acc_account_number])
GO
ALTER TABLE [dbo].[acc_transactions] ADD CONSTRAINT [FK_acc_transactions_act_branches_departments] FOREIGN KEY ([atrn_branch_id], [atrn_department_code]) REFERENCES [dbo].[act_branches_departments] ([brdep_branch_id], [brdep_department_code])
GO
ALTER TABLE [dbo].[acc_transactions] ADD CONSTRAINT [FK_acc_transactions_nm_payment_modes] FOREIGN KEY ([atrn_payment_code]) REFERENCES [dbo].[nm_payment_modes] ([pm_payment_code])
GO
ALTER TABLE [dbo].[acc_transactions] ADD CONSTRAINT [FK_acc_transactions_nm_transactions_types] FOREIGN KEY ([atrn_type_code]) REFERENCES [dbo].[nm_transactions_types] ([trnt_type_code])
GO
ALTER TABLE [dbo].[acc_transactions] ADD CONSTRAINT [FK_acc_transactions_usr_users] FOREIGN KEY ([atrn_user_code]) REFERENCES [dbo].[usr_users] ([usr_user_code])
GO
