为 Sakila 数据仓库创建 Actor 维度
Creating Actor Dimension for Sakila Data Warehouse
我正在使用 Sakila 示例数据库创建数据仓库,以了解数据仓库的工作原理。
这是 Sakila 数据库的结构:https://dev.mysql.com/doc/sakila/en/sakila-structure.html。这是关于视频租赁的,它应该是不言自明的。
我有一个事实 table 和一个衡量标准,即 payment
table 中每次租金的付款金额。我现在创建了 3 个维度,时间、位置和电影维度。
现在我想创建一个 Actor 维度,来回答问题 "which actors are the most popular in our rentals?" 但是想了想,我卡住了。这是我的问题。
创建电影维度很简单,每笔付款大约是一部电影。所以在我的事实 table 中,对于每个 payment_id
我都有一个对应的 film_id
,这将是我的事实 table 和电影维度之间的外键。但是电影和演员之间存在 N-N 关系(通过 table film_actor
),所以我不知道将哪个外键放入我的事实 table 到 link 到相应的演员,因为每个 payment_id
都需要 linked 到 0..n actor_id
s.
希望您能理解我的问题。任何帮助将不胜感激。
你需要一座桥 table。
这是一个 Kimball 参考,但它使用了一个困难的例子:
http://www.kimballgroup.com/2012/02/design-tip-142-building-bridges/
这里有更好的解释,尽管示例并不完全符合您的需要:
http://www.askjohnobiee.com/2013/08/how-to-bridge-tables-and-many-to-many.html
据我所知,关于 Bridge table 的最佳讨论是 Christopher Adamson 的书 "Star Schema - The Complete Reference" 的第 9 章。如果您正在建造立体仓库,那么非常值得购买。您会在我们的书架上找到它的链接:
我正在使用 Sakila 示例数据库创建数据仓库,以了解数据仓库的工作原理。
这是 Sakila 数据库的结构:https://dev.mysql.com/doc/sakila/en/sakila-structure.html。这是关于视频租赁的,它应该是不言自明的。
我有一个事实 table 和一个衡量标准,即 payment
table 中每次租金的付款金额。我现在创建了 3 个维度,时间、位置和电影维度。
现在我想创建一个 Actor 维度,来回答问题 "which actors are the most popular in our rentals?" 但是想了想,我卡住了。这是我的问题。
创建电影维度很简单,每笔付款大约是一部电影。所以在我的事实 table 中,对于每个 payment_id
我都有一个对应的 film_id
,这将是我的事实 table 和电影维度之间的外键。但是电影和演员之间存在 N-N 关系(通过 table film_actor
),所以我不知道将哪个外键放入我的事实 table 到 link 到相应的演员,因为每个 payment_id
都需要 linked 到 0..n actor_id
s.
希望您能理解我的问题。任何帮助将不胜感激。
你需要一座桥 table。
这是一个 Kimball 参考,但它使用了一个困难的例子:
http://www.kimballgroup.com/2012/02/design-tip-142-building-bridges/
这里有更好的解释,尽管示例并不完全符合您的需要:
http://www.askjohnobiee.com/2013/08/how-to-bridge-tables-and-many-to-many.html
据我所知,关于 Bridge table 的最佳讨论是 Christopher Adamson 的书 "Star Schema - The Complete Reference" 的第 9 章。如果您正在建造立体仓库,那么非常值得购买。您会在我们的书架上找到它的链接: