一个表中的多个外键 [英] Multiple foreign keys from one table

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

问题描述

美好的一天伙计们,



我有关于正常化的问题。我有2张桌子,一张有位置,一张有旅行。为了完成旅行,它包括2个位置,并且位置表被标准化。我的旅行表有可能有2个外键吗?你的答案将不胜感激。

解决方案

绝对。事实上,这是一种非常普遍的现象。只需继续在表中创建两个外键,一切都会好的。正如佐尔坦在对这个问题的评论中指出的那样,这实际上是规范化过程中非常自然和基本的一部分。请参阅此文章以获得合适的解释:数据库规范化从密钥开始 [ ^ ]

Good day Guys,

I have a problem concerning normalization. I have 2 tables, one have locations and one has trips. in order a trip to be complete it consist of 2 locations and a location table is normalized. is it possible that my trip table can have 2 foreign keys? Your answers would be appreciated.

解决方案

Absolutely. In fact, that is a very common occurrance. Just go ahead and create both foreign keys in the table and all will be well. As Zoltan has pointed out in his comment to this question, this is actually a very natural and fundamental part of the normalization process. See this article for a decent explanation: Database normalization starts with the keys[^]


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

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