你为什么不可以加入粉丝陷阱? [英] Why can't you just join in fan trap?

查看:83
本文介绍了你为什么不可以加入粉丝陷阱?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解到底是什么是粉丝陷阱。

I'm trying to understand what exactly a fan trap is.

我不明白为什么您不知道销售代表处理的帐户?

I don't understand why can't you know the account a sales rep handles?

您不能只加入销售代表,分支机构和客户表格并找出答案吗?我想念什么?

Can't you just join the tables Sales Rep, Branch and Account and find out? What am I missing?

推荐答案

您可以加入以下内容的表/关系风扇陷阱。如果您认为生成的表/关系意味着它没有意义,那只会是一个陷阱。当然,如果您需要表/关系,您认为,则意味着您丢失了它,需要添加它。

You can join on the tables/relationships of a fan trap. It's only a trap if you think that the resulting table/relationship means something it doesn't. Of course, if you need the table/relationship you think it means then you are missing it and need to add it.

Works_for(rep,branch) -- (rows where) rep *rep* works for branch *branch*
Manages(branch,account) --(rows where) some branch *branch* rep manages account *account*

/* (rows where)
    rep *rep* works for branch *branch*
AND some branch *branch* rep manages account *account*
*/
Works_for NATURAL JOIN Manages

如果您认为该联接必须保持

If you think that that join must hold

/* (rows where)
    rep *rep* works for branch *branch*
AND rep *rep* manages account *account*
*/
Works_for_and_manages(rep, branch, account)

然后您就陷入了陷阱。

这两个联接谓词(语句模板)不相等(在每种情况下每一行的真值都不相同)时,基数约束的扇形模式成立。因此,它们的表并不总是具有相同的值。

The two join predicates (statement templates) are not equivalent (don't have the same truth value for every row in every situation) when that "fan" pattern of cardinality constraints hold. So their tables don't always hold the same value.

也许您会看到,如果每个分支机构只有一名员工,则他们将是等效的-谁必须管理所有员工帐户。但是,红衣主教就不会那么狂热。但是,这两个谓词的可能性更大,因此您不能从另一个谓词构造谓词/表/关系,而更好的设计是 Works_for

Maybe you can see that they would be equivalent if each branch had only one employee--who must manage all the accounts. But then the cardinalites wouldn't be fan-trappy. Much more likely than that however is that the two predicates aren't equivalent, so you can't construct either predicate/table/relationship from the other, and a better design has Works_for and

Manager(rep, account) -- (rows where) rep *rep* manages account *account*`

然后 Manages SELECT分支,帐户FROM Works_for NATURAL JOIN Manager 。即某些行,[rep * rep *的分支*分支*和rep * rep *管理帐户*帐户*] 。

(关系运算符产生的表具有某些逻辑运算符产生的谓词。 JOIN 对应于 AND UNION OR 等。这就是我们可以证明查询表达式返回所需的行。)

(Tables resulting from relation operators have predicates resulting from certain corresponding logic operators. JOIN corresponds to AND, UNION to OR, etc. That is how we can justify that a query expression returns the desired rows.)

这篇关于你为什么不可以加入粉丝陷阱?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆