I understand now yosiasz,
I'm going to put my full case study here, see if you can help me load the [FactProductSales] Fact table now.
-- Fact table
CREATE TABLE [dbo].[FactProductSales]
(
[TransactionId] [bigint] IDENTITY(1,1) NOT NULL, -- Surrogate Key
[SalesDateKey] [int] NULL, -- Pk [DimDate]
[StoreID] [int] NOT NULL, -- Pk [DimStores]
[CustomerID] [int] NOT NULL,-- Pk [DimCustomer]
[ProductID] [int] NOT NULL, -- Pk [DimProduct]
[SalesPersonID] [int] NOT NULL,-- Pk [DimSalesPerson]
[Quantity] [float] NULL,
[SalesTotalCost] [money] NULL,
[ProductActualCost] [money] NULL
) ON [PRIMARY]
====================================================================================
Go
CREATE TABLE [dbo].[DimCustomer]
(
[CustomerID] [int] IDENTITY(1,1) NOT NULL,
[CustomerAltID] varchar NOT NULL,
[CustomerName] varchar NULL,
[Gender] varchar NULL,
CONSTRAINT [pk_DimCustomer] PRIMARY KEY CLUSTERED
(
[CustomerID] ASC
)
) ON [PRIMARY]
=====================================================================================
go
CREATE TABLE [dbo].[DimDate]
(
[DateKey] [int] NOT NULL,
[Date] [datetime] NULL,
[FullDate] char NULL,
[DayOfMonth] varchar NULL,
[DayName] varchar NULL,
[DayOfWeek] char NULL,
[DayOfYear] varchar NULL,
[Month] varchar NULL,
[MonthName] varchar NULL,
[Year] char NULL,
[IsWeekday] [bit] NULL,
CONSTRAINT [pk_DateKey] PRIMARY KEY CLUSTERED
(
[DateKey] ASC
)
) ON [PRIMARY]
===================================================================================
Go
CREATE TABLE [dbo].[DimProduct]
(
[ProductKey] [int] IDENTITY(1,1) NOT NULL,
[ProductAltKey] varchar NOT NULL,
[ProductName] varchar NULL,
[ProductActualCost] [money] NULL,
[ProductSalesCost] [money] NULL,
CONSTRAINT [pk_DimProduct] PRIMARY KEY CLUSTERED
(
[ProductKey] ASC
)
) ON [PRIMARY]
go
===========================================================================
CREATE TABLE [dbo].[DimSalesPerson]
(
[SalesPersonID] [int] IDENTITY(1,1) NOT NULL,
[SalesPersonAltID] varchar NOT NULL,
[SalesPersonName] varchar NULL,
[StoreID] [int] NULL,
[City] varchar NULL,
[State] varchar NULL,
[Country] varchar NULL,
CONSTRAINT [pk_DimSalesPerson] PRIMARY KEY CLUSTERED
(
[SalesPersonID] ASC
)
) ON [PRIMARY]
go
======================================================================================
CREATE TABLE [dbo].[DimStores]
(
[StoreID] [int] IDENTITY(1,1) NOT NULL,
[StoreAltID] varchar NOT NULL,
[StoreName] varchar NULL,
[StoreLocation] varchar NULL,
[City] varchar NULL,
[State] varchar NULL,
[Country] varchar NULL,
CONSTRAINT [pk_DimStores] PRIMARY KEY CLUSTERED
(
[StoreID] ASC
)
) ON [PRIMARY]
=====================================================================================
_Keny