0% found this document useful (0 votes)
15 views2 pages

Datawarehouse

The document creates several database tables including a fact table and dimension tables to store sales data. It defines the columns for each table and establishes foreign key relationships between the tables.

Uploaded by

paul havard
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

Datawarehouse

The document creates several database tables including a fact table and dimension tables to store sales data. It defines the columns for each table and establishes foreign key relationships between the tables.

Uploaded by

paul havard
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Create Table FactProductSales

(
SalesDate int,
SalesAmount int,
Store int not null,
Customer int not null,
Product int not null,
Quantity float,
Employee int,
)
Go

Create table DimProduct


(
ProductSK int primary key identity,
ProductID varchar(10)not null,
ProductName varchar(100),
ProductType varchar,
ListPrice numeric,

)
Go

Create table DimStores


(
StoreSK int primary key identity,
StoreID varchar(10)not null,
StoreName varchar(100),
StoreAdress varchar(100),

)
Go

Create table DimSalesDate


(
DateSK int primary key identity,
FullDate date not null,
CalenderYear date,
MonthName date,
MonthNumber int,
SaleYear int,
)
Go

Create table DimCustomer


(
CustomerSK int primary key identity,
FirstName varchar(10) not null,
LastName varchar(50),
CustomerAddress varchar(20)
)
go

Create table DimEmployee


(
EmployeeSK int primary key identity,
EmployeeID varchar(10) not null,
EmployeeName varchar(50),
)
Go

AlTER TABLE FactProductSales ADD CONSTRAINT


FK_StoreSK FOREIGN KEY (StoreSK)REFERENCES DimStores(StoreSK);
AlTER TABLE FactProductSales ADD CONSTRAINT
FK_CustomerSK FOREIGN KEY (CustomerSK)REFERENCES Dimcustomer(CustomerSK);
AlTER TABLE FactProductSales ADD CONSTRAINT
FK_ProductSK FOREIGN KEY (ProductSK)REFERENCES Dimproduct(ProductSK);
AlTER TABLE FactProductSales ADD CONSTRAINT
FK_DateSK FOREIGN KEY (DateSK)REFERENCES DimsalesDate(DateSK);
Go
AlTER TABLE FactProductSales ADD CONSTRAINT
FK_EmployeeSK FOREIGN KEY (EmployeeSK)REFERENCES DimEmployee(EmployeeSK);
Go
AlTER TABLE FactProductSales ADD CONSTRAINT
FK_SalesTimeKey FOREIGN KEY (SalesTimeKey)REFERENCES DimDate(TimeKey);
Go

You might also like