CREATE TABLE [dbo].[ATFieldInstanceDate] (
    [FieldInstanceID] INT           NOT NULL IDENTITY(1,1),
    [FieldID]         INT           NOT NULL,
    [FieldValue]      DATETIME      NULL,
    [WorkItemID]      INT           NOT NULL,
    [FieldName]       NVARCHAR (64) NOT NULL,
    CONSTRAINT [PK_ATFieldInstanceDate] PRIMARY KEY NONCLUSTERED ([FieldInstanceID] ASC),
    CONSTRAINT [ATFieldInstanceDate_ATFieldDefinition] FOREIGN KEY ([FieldID]) REFERENCES [dbo].[ATFieldDefinition] ([FieldID]),
    CONSTRAINT [ATFieldInstanceDate_ATWorkItem] FOREIGN KEY ([WorkItemID]) REFERENCES [dbo].[ATWorkItem] ([WorkItemId])
);


GO
CREATE NONCLUSTERED INDEX [ATFieldInstanceDate_IX_FId]
    ON [dbo].[ATFieldInstanceDate]([FieldID] ASC);


GO
CREATE NONCLUSTERED INDEX [ATFieldInstanceDate_IX_FName]
    ON [dbo].[ATFieldInstanceDate]([FieldName] ASC);


GO
CREATE NONCLUSTERED INDEX [ATFieldInstanceDate_IX_WIId]
    ON [dbo].[ATFieldInstanceDate]([WorkItemID] ASC);

