﻿CREATE TABLE [dbo].[CRT_Data_5Minutes] (
    [CRTD_ID]              INT          IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL,
    [CRTD_Period]          DATETIME     NOT NULL,
    [CRTD_FirstQuote]      DATETIME     NOT NULL,
    [CRTD_LastQuote]       DATETIME     NOT NULL,
    [CRTD_PairSymbol]      VARCHAR (50) NOT NULL,
    [CRTD_BidOpeningValue] FLOAT (53)   NOT NULL,
    [CRTD_BidClosingValue] FLOAT (53)   NOT NULL,
    [CRTD_BidLowValue]     FLOAT (53)   NOT NULL,
    [CRTD_BidHighValue]    FLOAT (53)   NOT NULL,
    [CRTD_MidOpeningValue] FLOAT (53)   NOT NULL,
    [CRTD_MidClosingValue] FLOAT (53)   NOT NULL,
    [CRTD_MidLowValue]     FLOAT (53)   NOT NULL,
    [CRTD_MidHighValue]    FLOAT (53)   NOT NULL,
    [CRTD_DateIn]          DATETIME     CONSTRAINT [DF_CRT_Data_5Minutes_CRTD_DateIn] DEFAULT (getdate()) NOT NULL,
    [ExchangeId] INT NULL, 
    CONSTRAINT [PK_NC_dbo_CRT_Data_5Minutes_#CRTD_ID] PRIMARY KEY NONCLUSTERED ([CRTD_ID] ASC)
);


GO
CREATE NONCLUSTERED INDEX [IX_CRT_Data_5Minutes_CRTD_PairSymbol_Period_INC]
    ON [dbo].[CRT_Data_5Minutes]([CRTD_PairSymbol] ASC, [CRTD_Period] DESC)
    INCLUDE([CRTD_BidOpeningValue], [CRTD_BidClosingValue], [CRTD_BidLowValue], [CRTD_BidHighValue], [CRTD_MidOpeningValue], [CRTD_MidClosingValue], [CRTD_MidLowValue], [CRTD_MidHighValue]);

