多对多的表关系困境 [英] many to many table relationship dilemma

查看:138
本文介绍了多对多的表关系困境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过建立一个brigde表我会链接许多推销员和组在一起

by constructing a brigde table I would link many salesman and group together

我做了三个表如下

salesman
========
uId

salesGroupLinked
================
uId
groupId

group
======
groupId

所以它应该能够允许1个推销员可以有多个组,还有许多组可以拥有1个推销员。但现在我想扩大关系。

so it should be able to allow 1 salesman can have many groups and also many groups can own by 1 salesman. But now I thought of expand the relationship.

我想让每个推销员可以为每个组的他们的表现得分。我应该在哪里放置柱子?如果它在组表,则它已过时,因为groupId是唯一的,因此它可以给许多销售人员一个分数。

Says I want each salesman can have their performances score for each group. Where should I put the column? If it's at group table then it's obsoleted, because groupId is unique, so it may give a score to many salesman.

推荐答案

只是想想问题:绩效分数的关键是什么?它是一个推销员组的设置。所以,设置应该在它们链接的表上。对于(salesman,group)

Just by thinking about the problem: What is the key of the performance score? It is settings of one salesman's group. So, the settings should be on the table where they are linked. It will be unique for each pair of (salesman, group).

的每一对都是唯一的。 p>

So the table would look like

salesGroupLinked
================
uId
groupId
PerformanceScore

这篇关于多对多的表关系困境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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