Unix Technical Forum

SQL to denormalize data

This is a discussion on SQL to denormalize data within the SQL Server Data Warehousing forums, part of the Microsoft SQL Server category; --> Guys I am trying to demoralize the source column in one of my tables so I can identify the ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server Data Warehousing

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 07:42 PM
Dave
 
Posts: n/a
Default SQL to denormalize data

Guys I am trying to demoralize the source column in one of my tables so

I can identify the combination of sources that the email was recruited
from.


I know I can do this with a while loop (or cursor) but I would really
prefer taking a
set based approach.

Also, please feel free to offer any ideas on a better way to model
this.


I would like to know if we recruited an email on web site A, web site
B, or web site A and B.


My data table looks something like #data_table and I want my result set

to look something like #hybrid_table.


Can anyone offer some advice on how to approach this problem?


Thanks for you suggestions!!!


--drop table #data_table
create table #data_table (email_id int,src_id int)
--raw data
insert into #data_table select 1,5
insert into #data_table select 1,6
insert into #data_table select 1,7


insert into #data_table select 2,5
insert into #data_table select 2,6
insert into #data_table select 2,7


insert into #data_table select 3,5
insert into #data_table select 3,6
insert into #data_table select 3,7


insert into #data_table select 4,5
insert into #data_table select 4,6


insert into #data_table select 5,5
insert into #data_table select 5,9
insert into #data_table select 5,4
insert into #data_table select 5,20


insert into #data_table select 6,20
insert into #data_table select 6,5
insert into #data_table select 6,9
insert into #data_table select 6,4


--DROP TABLE #hybrid_table
create table #hybrid_table (hybrid_id int identity(1,1),hybrid_name
varchar(50))
insert into #hybrid_table (hybrid_name) SELECT '5,6,7'
insert into #hybrid_table (hybrid_name) SELECT '5,6'
insert into #hybrid_table (hybrid_name) SELECT '4,5,9,20'


select * from #data_table order by email_id,src_id
select * from #hybrid_table

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 07:42 PM
Adam Machanic
 
Posts: n/a
Default Re: SQL to denormalize data

"Dave" <daveg.01@gmail.com> wrote in message
news:1133303678.372420.276920@z14g2000cwz.googlegr oups.com...
> Guys I am trying to demoralize the source column in one of my tables so
> I can identify the combination of sources that the email was recruited
> from.


Can you explain why denormalizing would help you make that
determination?


--
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 07:42 PM
daveg.01@gmail.com
 
Posts: n/a
Default Re: SQL to denormalize data

I guess that is what I am asking too.

I have one email fact. I need to know what site I recruited this email
from. It was recruited from 2 sites. I want to give both credit since
both are good sources for recruiting emails.

How can you model this?

I think it is best to create a hybrid source dimension.


Source Dimension
Category Site Cost Per Email
Partner A Site 1 $1
Partner A Site 2 $10000

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 07:42 PM
daveg.01@gmail.com
 
Posts: n/a
Default Re: SQL to denormalize data

Just wanted to bump this.

Does anyone have any suggestions on how to model this scenerio?

How about someing like below?
Source Dimension
Category Site Cost Per Email
Partner A Site 1 $1
Partner A Site 2 $10000
Hybrid Site 1,2 $10001

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:08 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com