CREATE TABLE [dbo].[ATExportDefinition] (
    [Id] INT IDENTITY(1,1) NOT NULL,
    [ProcessId] INT NOT NULL,
    [ExportTypeId] INT NULL,
    [DoneFlagId] INT NULL,
    [ExportFileFormatId] INT NULL, -- ATImportDocumentType (DOC, TXT, XML) WHERE Convertible is true
    [TemplateId] INT NOT NULL,
    CONSTRAINT [PK_ATExportDefinition] PRIMARY KEY CLUSTERED ([Id]),
    CONSTRAINT [FK_ATExportDefinition_DoneFlag] FOREIGN KEY ([DoneFlagId]) REFERENCES [dbo].[ATExportFlagTxt]([Id]),
    CONSTRAINT [FK_ATExportDefinition_TemplateId] FOREIGN KEY ([TemplateId]) REFERENCES [dbo].[ATTemplates]([Id]),
    CONSTRAINT [FK_ATExportDefinition_ExportTypeId] FOREIGN KEY ([ExportTypeId]) REFERENCES [dbo].[ATExportType]([Id]),
    CONSTRAINT [FK_ATExportDefinition_ExportFileFormatId] FOREIGN KEY ([ExportFileFormatId]) REFERENCES [dbo].[ATImportDocumentType] ([Id])
);
