开发者

Need SQL-Server advice on how to make m2m relationships

开发者 https://www.devze.com 2023-02-04 18:28 出处:网络
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.

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 shou开发者_Python百科ld 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消