CREATE TABLE [dbo].[act_clients]
(
[cli_actor_id] [int] NOT NULL,
[cli_rowver] [timestamp] NOT NULL,
[cli_prof_code] [dbo].[ais_code_short] NULL,
[cli_fam_code] [dbo].[ais_code_short] NULL,
[cli_csp_code] [dbo].[ais_code_short] NULL,
[cli_culture_code] [dbo].[ais_code_short] NOT NULL,
[cli_vip] [bit] NOT NULL CONSTRAINT [DF__act_clients__cli_vip] DEFAULT ((0)),
[cli_black_list] [bit] NOT NULL CONSTRAINT [DF__act_clients__cli_black_list] DEFAULT ((0)),
[cli_statut_code] [dbo].[ais_code_short] NOT NULL,
[cli_user_code] [dbo].[ais_code_medium] NOT NULL,
[cli_type_code__cts] [dbo].[ais_code_short] NULL,
[cli_branch_id] [int] NOT NULL,
[cli_department_code] [dbo].[ais_code_medium] NOT NULL,
[cli_send_mail_for_offers] [bit] NOT NULL CONSTRAINT [DF__act_clients__cli_send_mail_for_offers] DEFAULT ((0)),
[cli_send_mail_for_pn] [bit] NOT NULL CONSTRAINT [DF__act_clients__cli_send_mail_for_pn] DEFAULT ((0)),
[cli_send_mail_for_pr] [bit] NOT NULL CONSTRAINT [DF__act_clients__cli_send_mail_for_pr] DEFAULT ((0)),
[cli_send_mail_for_ur] [bit] NOT NULL CONSTRAINT [DF__act_clients__cli_send_mail_for_ur] DEFAULT ((0)),
[cli_send_mail_for_fn] [bit] NOT NULL CONSTRAINT [DF__act_clients__cli_send_mail_for_fn] DEFAULT ((0)),
[cli_send_mail_for_fnr] [bit] NOT NULL CONSTRAINT [DF__act_clients__cli_send_mail_for_fnr] DEFAULT ((0)),
[cli_send_mail_for_cs] [bit] NOT NULL CONSTRAINT [DF__act_clients__cli_send_mail_for_cs] DEFAULT ((0)),
[cli_send_mail_for_ct] [bit] NOT NULL CONSTRAINT [DF__act_clients__cli_send_mail_for_ct] DEFAULT ((0)),
[cli_introducer_id] [int] NULL,
[cli_activity_code] [dbo].[ais_code_short] NULL,
[cli_registry_number] [varchar] (50) COLLATE French_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[act_clients] ADD CONSTRAINT [PK_act_clients] PRIMARY KEY CLUSTERED  ([cli_actor_id]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_act_clients_registry_number] ON [dbo].[act_clients] ([cli_registry_number]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[act_clients] ADD CONSTRAINT [FK_act_clients_acc_cts_types] FOREIGN KEY ([cli_type_code__cts]) REFERENCES [dbo].[acc_cts_types] ([ctstyp_type_code])
GO
ALTER TABLE [dbo].[act_clients] ADD CONSTRAINT [FK_act_clients_act_actors] FOREIGN KEY ([cli_actor_id]) REFERENCES [dbo].[act_actors] ([act_actor_id])
GO
ALTER TABLE [dbo].[act_clients] ADD CONSTRAINT [FK_act_clients_act_branches_departments] FOREIGN KEY ([cli_branch_id], [cli_department_code]) REFERENCES [dbo].[act_branches_departments] ([brdep_branch_id], [brdep_department_code])
GO
ALTER TABLE [dbo].[act_clients] ADD CONSTRAINT [FK_act_clients_act_csp] FOREIGN KEY ([cli_fam_code], [cli_csp_code]) REFERENCES [dbo].[act_csp] ([csp_fam_code], [csp_csp_code])
GO
ALTER TABLE [dbo].[act_clients] ADD CONSTRAINT [FK_act_clients_act_introducers] FOREIGN KEY ([cli_introducer_id]) REFERENCES [dbo].[act_introducers] ([int_actor_id])
GO
ALTER TABLE [dbo].[act_clients] ADD CONSTRAINT [FK_act_clients_act_profesions] FOREIGN KEY ([cli_prof_code]) REFERENCES [dbo].[nm_professions] ([nmprof_prof_code])
GO
ALTER TABLE [dbo].[act_clients] ADD CONSTRAINT [FK_act_clients_md_cultures] FOREIGN KEY ([cli_culture_code]) REFERENCES [dbo].[md_cultures] ([clt_culture_code]) ON UPDATE CASCADE
GO
ALTER TABLE [dbo].[act_clients] ADD CONSTRAINT [FK_act_clients_nm_activities] FOREIGN KEY ([cli_activity_code]) REFERENCES [dbo].[nm_activities] ([ape_activity_code])
GO
ALTER TABLE [dbo].[act_clients] ADD CONSTRAINT [FK_act_clients_nm_status_clients] FOREIGN KEY ([cli_statut_code]) REFERENCES [dbo].[nm_status_clients] ([nmscli_statut_code])
GO
ALTER TABLE [dbo].[act_clients] ADD CONSTRAINT [FK_act_clients_usr_users] FOREIGN KEY ([cli_user_code]) REFERENCES [dbo].[usr_users] ([usr_user_code])
GO
