CREATE TABLE [dbo].[dyn_forms_used_fields]
(
[frmuf_form_code] [dbo].[ais_code_short] NOT NULL,
[frmuf_table_name] [dbo].[ais_name] NOT NULL,
[frmuf_field_name] [dbo].[ais_name] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[dyn_forms_used_fields] ADD CONSTRAINT [PK_dyn_forms_used_fields] PRIMARY KEY CLUSTERED  ([frmuf_form_code], [frmuf_table_name], [frmuf_field_name]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[dyn_forms_used_fields] ADD CONSTRAINT [FK_dyn_forms_used_fields_dyn_forms] FOREIGN KEY ([frmuf_form_code]) REFERENCES [dbo].[dyn_forms] ([frm_form_code]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[dyn_forms_used_fields] ADD CONSTRAINT [FK_dyn_forms_used_fields_md_fields_cpl] FOREIGN KEY ([frmuf_table_name], [frmuf_field_name]) REFERENCES [dbo].[md_fields_cpl] ([fld_table_name], [fld_field_name])
GO
