Fact Table and Dimension Table

Fact   Table:  


    A   fact   table   typically   contains   the   business   fact   data   such   as   sales   amount,   sales   quantity,   the   number   of   customers,   and   the   foreign   keys   to   dimension   tables.  
   
  Dimension   Table:  


   Dimension   tables   contain   detailed   information   relevant   to   specific   attributes   of   the   fact   data,   such   as   details   of   the   product,   customer   attributes,   store   information,   and   so   on.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Blink SQL 支持在维表(dimension table)和事实表(fact table)之间进行 join 操作,以便在查询中使用维表的属性。维表通常包含静态数据,例如产品信息、客户信息等,而事实表则包含动态数据,例如销售记录、订单记录等。 维表 join 的语法如下: ```sql SELECT fact_table.*, dim_table.* FROM fact_table JOIN dim_table ON fact_table.dimension_column = dim_table.dimension_column ``` 其中,`fact_table` 是事实表,`dim_table` 是维表,`dimension_column` 是两个表中共同的维度列。在 join 操作中,通过将维度列作为 join 条件,将事实表中的每一行与维表中匹配的行进行组合。这样,查询结果将包含事实表和维表的所有列。 举个例子,假设有一个事实表 `sales_fact` 包含销售记录,和一个维表 `product_dim` 包含产品信息。如果我们想要查询某个时间范围内的销售记录,并且需要显示每个产品的名称和价格等信息,可以使用如下的 SQL 语句: ```sql SELECT sales_fact.*, product_dim.product_name, product_dim.price FROM sales_fact JOIN product_dim ON sales_fact.product_id = product_dim.product_id WHERE sales_fact.order_date BETWEEN '2022-01-01' AND '2022-01-31' ``` 在这个查询中,我们通过 `JOIN` 操作将事实表 `sales_fact` 和维表 `product_dim` 进行了组合,并通过 `ON` 子句指定了维度列 `product_id` 作为 join 条件。最终的查询结果将包含销售记录和产品信息的所有列,并限制了销售日期在 2022 年 1 月份的记录。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值