CREATE TABLE [dbo].[ATFieldInstanceNumber] (
    [FieldInstanceID] INT              NOT NULL IDENTITY(1,1),
    [FieldID]         INT              NOT NULL,
    [FieldValue]      NUMERIC (28, 14) NULL,
    [WorkItemID]      INT              NOT NULL,
    [FieldName]       NVARCHAR (64)    NOT NULL,
    CONSTRAINT [PK_ATFieldInstanceNumber] PRIMARY KEY NONCLUSTERED ([FieldInstanceID] ASC),
    CONSTRAINT [ATFieldInstanceNumber_ATFieldDefinition] FOREIGN KEY ([FieldID]) REFERENCES [dbo].[ATFieldDefinition] ([FieldID]),
    CONSTRAINT [ATFieldInstanceNumber_ATWorkItem] FOREIGN KEY ([WorkItemID]) REFERENCES [dbo].[ATWorkItem] ([WorkItemId])
);


GO
CREATE NONCLUSTERED INDEX [ATFieldInstanceNumber_IX_FId]
    ON [dbo].[ATFieldInstanceNumber]([FieldID] ASC);


GO
CREATE NONCLUSTERED INDEX [ATFieldInstanceNumber_IX_FName]
    ON [dbo].[ATFieldInstanceNumber]([FieldName] ASC);


GO
CREATE NONCLUSTERED INDEX [ATFieldInstanceNumber_IX_WIId]
    ON [dbo].[ATFieldInstanceNumber]([WorkItemID] ASC);

