CREATE TABLE [dbo].[ManagedConsumables]
(
[DeviceID] [int] NOT NULL,
[ConsumableHashCode] [int] NOT NULL,
[ConsumableName] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[ConsumableRemainingLevel] [float] NOT NULL,
[HigherValueThreshold] [float] NOT NULL,
[StaleUnits] [smallint] NOT NULL,
[StaleInterval] [smallint] NOT NULL,
[EstimatedStaleDate] [datetime] NOT NULL,
[ConsumableTypeExtended] [smallint] NOT NULL CONSTRAINT [DF_ManagedConsumables_ConsumableTypeExtended] DEFAULT ((0)),
[IsMarkedOnActionPerformed] [bit] NOT NULL CONSTRAINT [DF_ManagedConsumables_IsMarkedOnActionPerformed] DEFAULT ((0)),
[DismissDate] [datetime] NULL,
[DismissedByContactID] [int] NULL,
[IsNormalizedSupply] [bit] NULL CONSTRAINT [DF_ManagedConsumables_IsNormalizedSupply] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ManagedConsumables] ADD CONSTRAINT [PK_ManagedConsumables_DeviceID_ConsumableHashCode] PRIMARY KEY CLUSTERED ([DeviceID], [ConsumableHashCode]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ManagedConsumables] ADD CONSTRAINT [FK_ManagedConsumables_DeviceID_Device_DeviceID] FOREIGN KEY ([DeviceID]) REFERENCES [dbo].[Device] ([DeviceID]) ON DELETE CASCADE
GO