2015-07-21 35 views
1

我是数据仓库的新手,所以请容易在我身上。找出我的数据仓库中的维度表的数量

我想弄清楚在这种情况下的维数。

在我的交易数据库:

  • 我有一个表,该表存储位置代码。列是location_code int not null primary key, short_description varchar(10) not null, long_description varchar(100) not null

  • 我有一个存储区域代码的表。列是region_code int not null primary key, short_description varchar(10) not null, long_description varchar(100) not null

  • 我有一个关联位置和区域的表格。列是assoc_id int not null primary key, location_code int not null, region_code int not null。 1位置仅属于1个地区。

在我的数据仓库数据库用户可能希望按位置或按地区查找数据。

现在我期待在这种情况下,以创建维度表(一个或多个)。

想知道我应该创建2个维表(1位置和1区)这样?

  • 创建1代维度表的位置也有地区与这些列:region_code int not null primary key, region_short_description varchar(10) not null, region_long_description varchar(100) not null, location_code int not null, location_short_description varchar(10) not null, location_long_description varchar(100) not null

OR:location_code int not null primary key, location_short_description varchar(10) not null, location_long_description varchar(100) not null, region_code int not null, region_short_description varchar(10) not null, region_long_description varchar(100) not null

  • 的区域,该区域也具有与这些列位置创建1个维度表我要创建(对于地点区关联,1区域的定位协会1位置,1区,1)这样4个维度表?

    • 与这些列创建位置1个维度表:location_code int not null primary key, short_description varchar(10) not null, long_description varchar(100) not null

    • 与这些列创建1代维度表的地区:region_code int not null primary key, short_description varchar(10) not null, long_description varchar(100) not null

    • 与这些列的位置区关联创建1个维度表:location_code int not null, region_code int not null

    • 创建1代维度表与这些列区域的定位协会:region_code int not null, location_code int not null

    还是有另一种方式,也更有意义?如果是,请一定要告诉

    在数据仓库的世界里,什么样的关系是这样叫,什么是处理它的标准方式?

    感谢

  • +0

    这是哪个流程的业务视图?要获得有意义的答案,您应该解释“数据”是什么以及位置和区域是什么。例如销售是“数据”吗?位置是属于某个位置的地理位置吗?地点可能重叠吗? – momobo

    +0

    @momobo数据是所有员工在特定位置工作的小时数。因此,例如位置L1的1500小时和位置L2的2400小时。位置是地理位置,位置不能重叠。一个地区有一个或多个地点。 1位置只能属于1个地区。 – ChumboChappati

    回答

    0

    我会模式在同一维度的位置UND地区(根据业务使用命名,例如D_Location,或D_Geography)。

    小时数将在事实数据表和事实数据表中F_Hour和D_Location将与代理键(Oracle中的序列或Sql服务器中的标识)连接。

    区域和位置的所有描述性列可以愉快地生活在D_Location中(当然区域不会被标准化,但通常是这样做的)。

    +0

    对于特定区域,您如何计算小时数? – ChumboChappati

    +0

    从F_Hour加入D_Location的F_Hour.keyLocation = D_Location.keyLocation其中D_Location.Region =“Region 01” – momobo

    0

    我想你不需要跟踪维度表中的位置和区域的关联。该关联可以在事实表中。

    我将创建2个维表D_Location & D_Region和1个事实表F_Hour

    D_Location:

    location_code int not null primary key, short_description varchar(10) not null, long_description varchar(100) not null 
    

    D_Region:

    region_code int not null primary key, short_description varchar(10) not null, long_description varchar(100) not null 
    

    F_Hour:

    hour_id int not null primary key, location_code int not null, region_code int not null, hours decimal(10,2) not null 
    

    F_Hour将有1 FK到D_Location和1 FK到D_Region

    要获取小时特定location_code(@location_code):

    select h.location_code, l.short_description, l.long_description, sum(h.hours) 
    from F_Hour h inner join D_Location l on h.location_code = l.location_code 
    where h.location_code = @location_code 
    group by h.location_code, l.short_description, l.long_description 
    order by h.location_code 
    

    要获取小时特定REGION_CODE(@region_code):

    select h.region_code, r.short_description, r.long_description, sum(h.hours) 
    from F_Hour h inner join D_Region r on h.region_code = r.region_code 
    where h.region_code = @region_code 
    group by h.region_code, r.short_description, r.long_description 
    order by h.region_code 
    

    是否有意义?

    +0

    这个看起来与事务数据库非常相似的总和(小时)可以考虑使用数据仓库解决方案吗?我不确定@momobo您对这个解决方案有什么看法? – ChumboChappati

    +0

    我认为它有效。只有,我只会使用一个维度,而我会使用代理键。 – momobo

    相关问题