简体   繁体   English

事实表的影响维度

[英]Reaffecting dimension of fact table

I am starting to build a star schema, and I like it ^^ 我开始构建星型模式,我喜欢它^^

I have a design problem with dimensional modeling. 我在尺寸建模方面存在设计问题。

I have a Fact table for each transaction in the star schema (highest grain) Something like that (simplified version) 我为星型模式(最高粒度)中的每个事务都有一个事实表(Fact table),类似这样的东西(简化版)

transaction_facts
- id
- account_dim
- date_dim
- status_dim
- amount

status_dim
- id
- code
- description
- final

For a transaction, the status is not clearly defined at process time. 对于事务,在处理时状态没有明确定义。 Most all of the status fall into these cases: 大多数情况都属于以下情况:

  • the transaction is ok 交易还可以
  • the transaction is ko 交易是ko
  • the transaction is ok, but to be confirmed. 交易尚可,但有待确认。

The last status is the problematic one, since I can receive the confirmation of the transaction few days (up to 10 and sometime, even more) after the original transaction. 最后一种状态是有问题的状态,因为我可以在原始交易后的几天(最多10天,有时甚至更多)收到交易确认。

How should I handle this kind of late change? 我应该如何处理这种较晚的更改? Intuitively, I would be tempted to just reaffect the existing transactions to the new dimension, but it make me think of 2 things: 凭直觉,我很想将现有交易重新影响到新的维度,但这使我想到了两件事:

  • Is it a good practice? 这是一个好习惯吗? (do not rewrite history etc...) (请勿重写历史记录等。)
  • How to handle this kind of change in BigQuery or Redshift or any append only system ? 如何处理BigQuery或Redshift或仅附加系统中的此类更改? On a very high amount of rows, it will be a problem since these systems don't work well with updates 在非常多的行上,这将是一个问题,因为这些系统不能很好地与更新配合使用

If 如果

  • this does not need to be a true "financial transaction" table AND 这不必是真正的“金融交易”表,并且
  • you don't need to keep a history of the values (eg what was the value as of some previous date) 您不需要保留值的历史记录(例如,截至上一日期的值是什么)

Then you can/should update the value. 然后,您可以/应该更新该值。

If using Redshift then you can do this efficiently by writing a batch of updates to a staging table (copy from s3) then applying these all in one go as an update. 如果使用Redshift,则可以通过将大量更新写入登台表(从s3复制)然后一次全部应用这些更新来有效地做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM