我正在尝试编写一个关系代数表达式(不使用除法)来挑选出' player'每个团队中都有这种情况。属性。 例如,如果我的表看起来像这样:
R2:
Team Player
1 x
1 y
2 x
3 x
3 y
3 z
4 x
4 z
我想回来:
Player
x
因为x是团队中每个团队中唯一存在的玩家。
允许的操作:我可以使用以下操作: 选择,项目,重命名,连接(自然,交叉,内部,外部),设置减号,设置交集,聚合,如总和,计数,平均和分组
我的尝试:
R1 = (already given, distinct list of Teams) [1,2,3,4]
R2 = the table as stated above
R3 = Count[Team](R1) # number of distinct teams
R4 = GroupBy[Player]_Count[team](R2) # no. of teams grouped by Player
R5 = R4 join[R4.count == R3.count] R3 # only those players with teams = total number of teams
R6 = PROJ[player](R5) # list of players that played in each team
这有意义吗?或者有更有效的方法吗?
为了提高我的理解,我也经历了明确的关系:
R1:
Team
1
2
3
4
R3:
Count
4
R4:
Player Count
x 4
y 2
z 2
R5:
Player Count
x 4
R6:
Player
x