仓库:存储(和计数)非事实记录?
如何存储不包含任何事实的记录?例如,假设一家商店想要统计有多少人进入商店(并且他们获取进入商店的每个人的信息)。在仓库中,我猜想会有具有不同属性的维度表“Person”,但是事实表会是什么样子呢?它只包含外键吗?
How to store records that don't contain any fact? For example, let's say that a shop wants to count how many people have entered inside a store (and that they take info on every person that goes inside the shop). In warehouse, I guess there would be dimension table "Person" with different attributes, but how would fact table look like? Would it contain only foreign keys?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如您所描述的,这只是一个事实表。实际上,这个有一个名字——无事实的事实表;没有任何措施的事实表。
重新编码事件很常见。本质上,任何记录:
谁、什么、哪里、何时以及为什么?
的内容都将是无事实测量的表。如果您添加多少?
,那么这将成为一个度量。As you described it, that would be just a fact table. Actually, there is name for this -- factless fact table; fact table without any measures.
It is quite common for recoding events. Essentially anything that records:
who, what, where, when and why?
would be fact-measure-less table. If you addhow much?
then that goes into a measure.您可以将其视为包含隐式计数列的事实表,其中包含进入的人数,如果您在个人级别存储数据,则该事实表始终为“1”,因此这使得事实表仅包含维度的 FK。
当然,这只能对进入的人数进行分析,并针对各个维度进行过滤,但对我来说,这似乎是一个现实的用例。我认为你走在正确的道路上。
You can think of it as the fact table containing an implicit count column, with the number of people entering, which is always "1" if you store data on individual person level, so that makes a fact table containing only FKs to the dimensions.
This of course only enabled analysis on the number of people entering, filtered for the various dimensions, but it seams like a realistic use case to me. I think you're on the right way.