规范化:单行中的两列需要来自同一个表的数据

发布于 2024-08-18 13:54:56 字数 100 浏览 4 评论 0原文

我有一个包含以下字段的表:

分配给和完成者

这些字段引用员工表。

我只是想知道这是否正常化或者我是否错过了一些东西。

谢谢

I have a table which has the following fields:

Assignedto and completedby

These fields reference the employee table.

I was just wondering if this is normalized or whether I have missed something.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

失眠症患者 2024-08-25 13:54:56

是的,将一个表中的多个列作为另一个表的外键是可以的(并且是适当的)。您的案例就是一个很好的例子...

实际上有很多例子 - 客户表可以有一个邮寄地址和一个送货地址,它们都指向一个地址表。联系人表可以有一个家庭电话、工作电话、传真和移动列都指向电话表(尽管还有其他更好的方法来执行此操作)

Yes, it is fine (and appropriate) to have more than one column in a table be a Foreign Key into another table. Your case is a good example of this...

There are lots of examples actually - A Customer Table can have a mailing address and a Delivery address, which both point to an Address table.. A Contact Table could have a HomePhone, WorkPhone, Fax, and Mobile column that all point to a Telephone table (although there are other better ways of doing this one)

谈下烟灰 2024-08-25 13:54:56

注意:我将您的第二个表称为“Stuff”,因为我不知道还能称呼它什么。

如果“AssignedTo”和“CompletedBy”字段都是 Employee 的外键,则为 3NF桌子。如果您确实想要进行规范化,可以使用第三个表 StuffCompletion,它具有标识列和这两个值,并将 Stuff 表中的这两个值替换为 StuffCompletion 的外键。我想大多数人都会认为这太过分了,模式之神可能会给你带来毁灭。

Note: I'll refer to your second table as "Stuff" since I don't know what else to call it.

It's 3NF if the AssignedTo and CompletedBy fields are both foreign keys to the Employee table. If you really want to go nuts with the normalization, you can have a third table, StuffCompletion, that has an identity column and those two values, and replace those two values in your Stuff table with a foreign key to StuffCompletion. I think most people would consider this overkill, and the schema gods may rain destruction upon you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文