首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >事实表的数据仓库设计

事实表的数据仓库设计
EN

Stack Overflow用户
提问于 2016-08-05 22:27:00
回答 1查看 219关注 0票数 1

我对数据仓库的设计非常陌生,并且很难考虑如何设计事实表,给出了非常相似但有点不同的度量标准。假设您正在评估以下指标,您将如何分解事实表(在本例中,公司是客户的子集)。您能使用一个表来处理所有这些问题吗?还是每个度量指标都需要它自己的事实表?还是度量的每一部分都是它在一个事实表中的一个列?

  • 公司每日/每月/每年处理的文件总数
  • 公司每日/每月/每年处理的文件总数
  • 公司每日/每月/年度#档案总数
  • 公司每日/每月/年度#文件总数失败
  • 客户每日/每月/每年处理的文件总数
  • 处理的客户每日/每月/年度文件总数
  • 客户每日/每月/年度#文件总数
  • 客户每日/每月/年度#文件总数失败
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-08-08 03:12:09

从度量名称的外观来看,我认为您将得到一个事实表,其中包含每个文件的记录和返回到一个date_dim的链接

代码语言:javascript
复制
create table date_dim (
    date_sk        int,
    calendar_date  date,
    month_ordinal  int,
    month_name     nvarchar,
    Year           int,
..etc you've got your own one of these ..
)
create table fact_file_measures (
    date_sk,
    file_sk,           --ref the file_dim with additonal file info
    company_sk,        --ref the company_dim with the client details
    processed  int,    --should always be one, optional depending on how your reporting team like to work
    size_Kb    decimal -- specifiy a size measurement, ambiguity is bad
    error_count int    -- 1 if file had error, 0 if fine
    failed_count int   -- 1 or file failed, 0 if fine
)

因此,现在您应该能够构造查询来获取所需的所有内容。

例如,对于每月的统计数据:

代码语言:javascript
复制
select 
    c.company_name,
    c.client_name,
    sum(f.file_count) total_files,
    sum(f.size_Kb)    total_files_size_Kb,
    sum(f.file_count) total_files,
    sum(f.file_count) total_files
from
    fact_file_measure f
    inner join dim_company c on f.company_sk = c.company_sk
    inner join dim_date d on f.date_sk = d.date_sk
where
    d.month = 'January' and d.year = "1984"

如果您需要同时使用“日/月/年”的内容,则可以构造年度和月份事实表来进行滚动,并通过date_date的月份/年份字段返回。(您可以在每日事实表中包括月份和年份字段,但是这些值最终可能会丢失-由经验较少的报表构建人员使用)--这可以追溯到用户实际需要的东西--根据用户的要求设计事实表,不要害怕有单独的事实表--数据仓库不是关于规范化,而是以一种可以使用的方式来表示数据。

祝好运

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38798536

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档