CREATE TABLE [dbo].[ATExternalTrackingDefinition] (
    Id INT IDENTITY(1,1) NOT NULL,
    TemplateId INT NOT NULL,
    DBTableName NVARCHAR(255) NOT NULL,
    SourceTypeId INT NOT NULL DEFAULT 3,
    SourceValue NVARCHAR(255) NOT NULL,
    DbColumnName NVARCHAR(255) NOT NULL,
    DBDataType NVARCHAR(50) NOT NULL,
    CONSTRAINT PK_ATExternalTrackingDefinition_Id PRIMARY KEY (Id),
    CONSTRAINT FK_ATExternalTrackingDefinition_TemplateId FOREIGN KEY (TemplateId) REFERENCES [dbo].[ATTemplates](Id),
    CONSTRAINT FK_ATExternalTrackingDefinition_SourceTypeId FOREIGN KEY (SourceTypeId) REFERENCES [dbo].[ATExternalTrackingSourceType](Id)
);