Unix Technical Forum

Design question

This is a discussion on Design question within the SQL Server Data Warehousing forums, part of the Microsoft SQL Server category; --> I have 2 tables like this: First table has rows indicating is someone comes in (InOut = 1 or ...


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

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 07:05 PM
Stijn Verrept
 
Posts: n/a
Default Design question

I have 2 tables like this:

First table has rows indicating is someone comes in (InOut = 1 or goes
out (InOut = 0)

InOut
SNID Date InOut
3 '2007-01-01' 0
4 '2007-01-15' 0
3 '2007-03-28' 1
5 '2007-01-01' 0
4 '2007-04-15' 1
5 '2007-02-12' 1

Second table indicates a category

Category
SNID Date Cat
3 '2007-01-01' 0
4 '2007-01-15' 4
3 '2007-04-16' 2
5 '2007-01-01' 2
4 '2007-03-15' 1
5 '2007-01-18' 3

I need to have a list of each week, month, year, ... with the number of
people present and their category:

Something like:

Date Cat Total
Jan 2007 0 31
Jan 2007 4 16
Feb 2007 ...

I can do the calculation each day and save the number to the
datawarehouse. But isn't it also possible to save the two tables to
the datawarehouse and have it do the calculations on the fly?

How can I do the second option? Is it with a slowly changing dimension?

--
Thanks in advance,

Stijn Verrept.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 07:05 PM
MC
 
Posts: n/a
Default Re: Design question

No, I would actually use T-SQL to calculate. It shouldnt take too long..
Something like (I would replace 0 with -a in InOut column):

select tbl2.category, tbl1.date, sum(tbl1.InOut) as NumberOfPeople
from
tbl1
inner join tbl2 on tbl1.date = tbl2.date and tbl1.SNID = tbl2.SNID
group by
tbl2.category, tbl1.date




MC

PS. You can optimize by using only recent changes or something....


"Stijn Verrept" <TURN_moc.tfosyrtne@njits_AROUND> wrote in message
news:yc6dnTCj_5dGYbDbnZ2dnUVZ8qSnnZ2d@scarlet.biz. ..
>I have 2 tables like this:
>
> First table has rows indicating is someone comes in (InOut = 1 or goes
> out (InOut = 0)
>
> InOut
> SNID Date InOut
> 3 '2007-01-01' 0
> 4 '2007-01-15' 0
> 3 '2007-03-28' 1
> 5 '2007-01-01' 0
> 4 '2007-04-15' 1
> 5 '2007-02-12' 1
>
> Second table indicates a category
>
> Category
> SNID Date Cat
> 3 '2007-01-01' 0
> 4 '2007-01-15' 4
> 3 '2007-04-16' 2
> 5 '2007-01-01' 2
> 4 '2007-03-15' 1
> 5 '2007-01-18' 3
>
> I need to have a list of each week, month, year, ... with the number of
> people present and their category:
>
> Something like:
>
> Date Cat Total
> Jan 2007 0 31
> Jan 2007 4 16
> Feb 2007 ...
>
> I can do the calculation each day and save the number to the
> datawarehouse. But isn't it also possible to save the two tables to
> the datawarehouse and have it do the calculations on the fly?
>
> How can I do the second option? Is it with a slowly changing dimension?
>
> --
> Thanks in advance,
>
> Stijn Verrept.



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 05:04 AM.


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