
/****** Object:  Table [dbo].[tbTransactionItem_partitioned]    Script Date: 5/26/2020 8:02:26 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tbTransactionItem_partitioned]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tbTransactionItem_partitioned](
	[TransactionItemID] [bigint] IDENTITY(1,1) NOT NULL,
	[EntityID] [bigint] NOT NULL,
	[ItemID] [bigint] NOT NULL,
	[Quantity] [float] NOT NULL,
	[TransactionTime] [datetime] NOT NULL,
	[InventoryCost] [money] NOT NULL,
	[TransactionSalesItemID] [bigint] NULL,
	[InventoryUnit] [varchar](50) NOT NULL,
	[BusinessDay] [smalldatetime] NULL,
	[Aggregated] [bit] NULL,
	[RevenueCentreID] [tinyint] NULL,
 CONSTRAINT [PK_tbTransactionItem_partitioned] PRIMARY KEY CLUSTERED 
(
	[TransactionItemID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [FG_TransactionItem1]
) ON [FG_TransactionItem1]
END
GO
/****** Object:  Index [IX_EntityID_BusinessDay]    Script Date: 5/26/2020 8:02:28 AM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[tbTransactionItem_partitioned]') AND name = N'IX_EntityID_BusinessDay')
CREATE NONCLUSTERED INDEX [IX_EntityID_BusinessDay] ON [dbo].[tbTransactionItem_partitioned]
(
	[EntityID] ASC,
	[BusinessDay] ASC
)
INCLUDE([ItemID],[Quantity],[InventoryCost]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [FG_TransactionItem1]
GO
/****** Object:  Index [tbTransactionItem_partitioned_IncludingInventoryCostQuantity]    Script Date: 5/26/2020 8:02:28 AM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[tbTransactionItem_partitioned]') AND name = N'tbTransactionItem_partitioned_IncludingInventoryCostQuantity')
CREATE NONCLUSTERED INDEX [tbTransactionItem_partitioned_IncludingInventoryCostQuantity] ON [dbo].[tbTransactionItem_partitioned]
(
	[EntityID] ASC,
	[ItemID] ASC,
	[TransactionTime] ASC
)
INCLUDE([Quantity],[InventoryCost]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [FG_TransactionItem1]
GO
