CREATE TABLE [dbo].[MetersHistory]
(
[AccountID] [int] NOT NULL,
[DeviceID] [int] NOT NULL,
[Year] [smallint] NOT NULL,
[Month] [tinyint] NOT NULL,
[FirstPrinterAuditID] [int] NOT NULL,
[LastPrinterAuditID] [int] NOT NULL,
[PageCountTotal] [bigint] NOT NULL,
[PageCountMono] [bigint] NULL,
[PageCountColor] [bigint] NULL,
[ContinuousSquareFeet] [float] NULL,
[LinearFeet] [float] NULL,
[TotalAverageVolume] [float] NULL,
[MonoAverageVolume] [float] NULL,
[ColorAverageVolume] [float] NULL,
[ContinuousSquareFeetAverage] [float] NULL,
[LinearFeetAverage] [float] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MetersHistory] ADD CONSTRAINT [PK_MetersHistory_AccountID_DeviceID_Year_Month] PRIMARY KEY CLUSTERED ([AccountID], [DeviceID], [Year], [Month]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MetersHistory] ADD CONSTRAINT [FK_MetersHistory_AccountID_Account_AccountID] FOREIGN KEY ([AccountID]) REFERENCES [dbo].[Account] ([AccountID])
GO
ALTER TABLE [dbo].[MetersHistory] ADD CONSTRAINT [FK_MetersHistory_DeviceID_Device_DeviceID] FOREIGN KEY ([DeviceID]) REFERENCES [dbo].[Device] ([DeviceID])
GO
ALTER TABLE [dbo].[MetersHistory] ADD CONSTRAINT [FK_MetersHistory_FirstPrinterAuditID_PrinterAudit_PrinterAuditID] FOREIGN KEY ([FirstPrinterAuditID]) REFERENCES [dbo].[PrinterAudit] ([PrinterAuditID])
GO
ALTER TABLE [dbo].[MetersHistory] ADD CONSTRAINT [FK_MetersHistory_LastPrinterAuditID_PrinterAudit_PrinterAuditID] FOREIGN KEY ([LastPrinterAuditID]) REFERENCES [dbo].[PrinterAudit] ([PrinterAuditID])
GO