CREATE TABLE [dbo].[md_grids_fields]
(
[grdf_grid_name] [dbo].[ais_name] NOT NULL,
[grdf_table_name] [dbo].[ais_name] NOT NULL,
[grdf_field_name] [dbo].[ais_name] NOT NULL,
[grdf_rowver] [timestamp] NOT NULL,
[grdf_order] [smallint] NOT NULL,
[grdf_width] [smallint] NULL,
[grdf_forceshow_if_hidden] [bit] NOT NULL CONSTRAINT [DF__md_grids_fields__grdf_forceshow_if_hidden] DEFAULT ((0)),
[grdf_calculated_column_expression] [nvarchar] (500) COLLATE French_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[md_grids_fields] ADD CONSTRAINT [PK_md_grids_fields] PRIMARY KEY CLUSTERED  ([grdf_grid_name], [grdf_table_name], [grdf_field_name]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[md_grids_fields] ADD CONSTRAINT [FK_md_grids_fields_md_fields_table_name] FOREIGN KEY ([grdf_table_name], [grdf_field_name]) REFERENCES [dbo].[md_fields] ([fld_table_name], [fld_field_name])
GO
ALTER TABLE [dbo].[md_grids_fields] ADD CONSTRAINT [FK_md_grids_fields_md_grids_grid_name] FOREIGN KEY ([grdf_grid_name]) REFERENCES [dbo].[md_grids] ([grd_grid_name]) ON UPDATE CASCADE
GO
