Loading data into fact table
2 posters
Page 1 of 1
Loading data into fact table
I'm trying to create and populate three dimensions and a fact tables with data. The dimensions work just fine but i'm unable to get any data into my fact table. If anyone will be so kind to point out what i'm doing wrong - i will be grateful.
Thank you all very much.
This is my code
[create table Customer
(
CUID integer identity(1,1) primary key,
Name varchar (25)
)
insert into Customer select distinct customer from [Data]
create table Agent
(
AID integer identity(1,1) primary key,
Agent varchar (25)
)
insert into Agent select distinct Seller from [Data]
create table Time
(
TID integer identity(1,1) primary key,
Week varchar (25),
Month varchar (25),
Year int
)
insert into Time
(Week,Month,Year)
select distinct Day,Month,Year from [Data]
Create Table Fact
(
CUID integer,
AID integer,
TID integer,
Sale money,
constraint pk_Fact primary key (CUID, AID, TID),
constraint fk1_Fact foreign key (CUID)
references Customer (CUID),
constraint fk2_Fact foreign key (AID)
references Agent (AID),
constraint fk3_Fact foreign key (TID)
references Time (TID),
)
insert into Fact
(CUID, AID, TID, Sale)
SELECT CUID, AID, TID, Sale
FROM Customer,
Agent,
Time,
[Data]]
Thank you all very much.
This is my code
[create table Customer
(
CUID integer identity(1,1) primary key,
Name varchar (25)
)
insert into Customer select distinct customer from [Data]
create table Agent
(
AID integer identity(1,1) primary key,
Agent varchar (25)
)
insert into Agent select distinct Seller from [Data]
create table Time
(
TID integer identity(1,1) primary key,
Week varchar (25),
Month varchar (25),
Year int
)
insert into Time
(Week,Month,Year)
select distinct Day,Month,Year from [Data]
Create Table Fact
(
CUID integer,
AID integer,
TID integer,
Sale money,
constraint pk_Fact primary key (CUID, AID, TID),
constraint fk1_Fact foreign key (CUID)
references Customer (CUID),
constraint fk2_Fact foreign key (AID)
references Agent (AID),
constraint fk3_Fact foreign key (TID)
references Time (TID),
)
insert into Fact
(CUID, AID, TID, Sale)
SELECT CUID, AID, TID, Sale
FROM Customer,
Agent,
Time,
[Data]]
dwnewbie- Posts : 2
Join date : 2013-01-20
Re:Loading data into fact table
Hi,
you have foreign key constraint on the fact tables to other dimension tables, when trying to insert into the fact are you getting a foreign key voilations.
thanks
Himanshu
you have foreign key constraint on the fact tables to other dimension tables, when trying to insert into the fact are you getting a foreign key voilations.
thanks
Himanshu
hkandpal- Posts : 113
Join date : 2010-08-16
Re: Loading data into fact table
hkandpal wrote:Hi,
you have foreign key constraint on the fact tables to other dimension tables, when trying to insert into the fact are you getting a foreign key voilations.
thanks
Himanshu
Yes i am. What did i do wrong?
dwnewbie- Posts : 2
Join date : 2013-01-20
Re: Loading data into fact table
If you are getting a FK voilation error then, it looks live those dim values are not present in your dimension table, check if your load dimension process is happening correctly.
thanks
Himanshu
thanks
Himanshu
hkandpal- Posts : 113
Join date : 2010-08-16
Similar topics
» Loading a Fact Table with SCD2
» Design a snapshot Fact table in data mart from compliance-enable fact table in enterprise data warehouse
» Loading data from one fact to another summary fact
» Loading fact table and dimension indexing.
» Loading Fact Table
» Design a snapshot Fact table in data mart from compliance-enable fact table in enterprise data warehouse
» Loading data from one fact to another summary fact
» Loading fact table and dimension indexing.
» Loading Fact Table
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum