需要有关如何建立 M2M 关系的 SQL-Server 建议
我有 4 个表:公司、个人、工作、员工。
前 3 个表需要与员工有一个或两个(不多不少)关系。
所以我的问题是我应该这样做,我应该向每个表添加两个字段“Employee1”和“Employee2”,将其中一个字段标记为可为空吗?
不然呢?
在弄脏桌子之前,我想听听专家的意见。
I have 4 tables: Company, Person, Job, Employee.
The first 3 tables need to have either one or two (no more no less) relationships to employee.
So my question is I should I do it, should I add two fields "Employee1" and "Employee2" to each of these tables marking one of them as nullable?
Or else?
I would like to hear from the experts before I am making my tables dirty.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当表格只需要引用员工一两次时,实际上没有太多选择。因为您不想创建这种复杂的模式,如果您需要支持的只是 Employee 表的一两个连接,那么这将造成一场联接的噩梦。
我想说采用添加 Employee1 和 Employee2 的解决方案。
There really isn't much choice when the table has to reference employees only one or two times. Because you don't want to create this complex schema that that is going to create a nightmare of joins if all you need to support is one or two connections the the Employee table.
I would say go with your solution of adding Employee1 and Employee2.