如何将表与其他众多表之一关联? [英] How to relate table with one of many others?
问题描述
我对数据库设计有点困惑。我有 orders
表,其中可能有许多其他记录之一。因此,可以将每个表以1:1关联到 orders
。请查看订单
域
和主机
表之间的关系。 / p>
我的订单
表行具有域
或托管
与其 orders_type
值有关。
您是否在问订单是否应该与域名具有1:1关系,而与托管又应具有1:1关系?如果是,答案是否定的。您的托管表中包含一个orders_id,这意味着您可以拥有多个具有相同订单的托管,即orders:hosting为1:M。
{关于域名,订单:domains => 1:M}
I am little confused about my db design. I have orders
table that may have records from one of many others. So is it OK to relate each tables with 1:1 to orders
. Please look at orders
domains
and hostings
table relations.
My orders
table rows has either a domain
or hosting
regarding to its orders_type
value.
Are you asking if the orders should have 1:1 relationship with domains and another 1:1 relationship with hostings? If you are, the answer is no. Your hosting table has an orders_id which implies means that you can have multiple hostings with the same order, i.e., orders:hosting is 1:M.
{Regarding domains, orders:domains => 1:M}
这篇关于如何将表与其他众多表之一关联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!