我对数据仓库的设计非常陌生,并且很难考虑如何设计事实表,给出了非常相似但有点不同的度量标准。假设您正在评估以下指标,您将如何分解事实表(在本例中,公司是客户的子集)。您能使用一个表来处理所有这些问题吗?还是每个度量指标都需要它自己的事实表?还是度量的每一部分都是它在一个事实表中的一个列?
发布于 2016-08-08 03:12:09
从度量名称的外观来看,我认为您将得到一个事实表,其中包含每个文件的记录和返回到一个date_dim的链接
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
)因此,现在您应该能够构造查询来获取所需的所有内容。
例如,对于每月的统计数据:
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的月份/年份字段返回。(您可以在每日事实表中包括月份和年份字段,但是这些值最终可能会丢失-由经验较少的报表构建人员使用)--这可以追溯到用户实际需要的东西--根据用户的要求设计事实表,不要害怕有单独的事实表--数据仓库不是关于规范化,而是以一种可以使用的方式来表示数据。
祝好运
https://stackoverflow.com/questions/38798536
复制相似问题