<small id='nTLz5'></small><noframes id='nTLz5'>

<legend id='nTLz5'><style id='nTLz5'><dir id='nTLz5'><q id='nTLz5'></q></dir></style></legend>

  • <tfoot id='nTLz5'></tfoot>
    <i id='nTLz5'><tr id='nTLz5'><dt id='nTLz5'><q id='nTLz5'><span id='nTLz5'><b id='nTLz5'><form id='nTLz5'><ins id='nTLz5'></ins><ul id='nTLz5'></ul><sub id='nTLz5'></sub></form><legend id='nTLz5'></legend><bdo id='nTLz5'><pre id='nTLz5'><center id='nTLz5'></center></pre></bdo></b><th id='nTLz5'></th></span></q></dt></tr></i><div id='nTLz5'><tfoot id='nTLz5'></tfoot><dl id='nTLz5'><fieldset id='nTLz5'></fieldset></dl></div>

          <bdo id='nTLz5'></bdo><ul id='nTLz5'></ul>
      1. 单个列的多个外键

        Multiple foreign keys to a single column(单个列的多个外键)
      2. <tfoot id='4Q44X'></tfoot>

          • <i id='4Q44X'><tr id='4Q44X'><dt id='4Q44X'><q id='4Q44X'><span id='4Q44X'><b id='4Q44X'><form id='4Q44X'><ins id='4Q44X'></ins><ul id='4Q44X'></ul><sub id='4Q44X'></sub></form><legend id='4Q44X'></legend><bdo id='4Q44X'><pre id='4Q44X'><center id='4Q44X'></center></pre></bdo></b><th id='4Q44X'></th></span></q></dt></tr></i><div id='4Q44X'><tfoot id='4Q44X'></tfoot><dl id='4Q44X'><fieldset id='4Q44X'></fieldset></dl></div>

              <tbody id='4Q44X'></tbody>
            <legend id='4Q44X'><style id='4Q44X'><dir id='4Q44X'><q id='4Q44X'></q></dir></style></legend>

              <small id='4Q44X'></small><noframes id='4Q44X'>

                  <bdo id='4Q44X'></bdo><ul id='4Q44X'></ul>
                  本文介绍了单个列的多个外键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在为客户/订单系统定义一个数据库,其中有两种高度不同的客户类型.因为它们是如此不同,只有一个客户表会非常难看(它会充满空列,因为它们对于一种类型毫无意义).

                  I'm defining a database for a customer/ order system where there are two highly distinct types of customers. Because they are so different having a single customer table would be very ugly (it'd be full of null columns as they are pointless for one type).

                  他们的订单虽然格式相同.是否可以在我的 Order 表中有一个 CustomerId 列,该列具有两种客户类型的外键?我已经在 SQL Server 中设置了它,它给我创建关系没有任何问题,但我还没有尝试插入任何数据.

                  Their orders though are in the same format. Is it possible to have a CustomerId column in my Order table which has a foreign key to both the Customer Types? I have set it up in SQL server and it's given me no problems creating the relationships, but I'm yet to try inserting any data.

                  另外,我打算使用 nHibernate 作为 ORM,这样做会不会有任何问题引入这样的关系?

                  Also, I'm planning on using nHibernate as the ORM, could there be any problems introduced by doing the relationships like this?

                  推荐答案

                  不,您不能将单个字段作为两个不同表的外键.你会如何知道去哪里找钥匙?

                  No, you can't have a single field as a foreign key to two different tables. How would you tell where to look for the key?

                  您至少需要一个字段来说明它是哪种用户,或者两个单独的外键.

                  You would at least need a field that tells what kind of user it is, or two separate foreign keys.

                  您还可以将所有用户通用的信息放在一个表中,并为特定于用户类型的信息使用单独的表,这样您就有一个以用户 ID 作为主键的表.

                  You could also put the information that is common for all users in one table and have separate tables for the information that is specific for the user types, so that you have a single table with user id as primary key.

                  这篇关于单个列的多个外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  SQL query to group by day(按天分组的 SQL 查询)
                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                  MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                  Include missing months in Group By query(在 Group By 查询中包含缺失的月份)
                  Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)

                      <tbody id='4ZFiB'></tbody>
                    <tfoot id='4ZFiB'></tfoot>

                    • <i id='4ZFiB'><tr id='4ZFiB'><dt id='4ZFiB'><q id='4ZFiB'><span id='4ZFiB'><b id='4ZFiB'><form id='4ZFiB'><ins id='4ZFiB'></ins><ul id='4ZFiB'></ul><sub id='4ZFiB'></sub></form><legend id='4ZFiB'></legend><bdo id='4ZFiB'><pre id='4ZFiB'><center id='4ZFiB'></center></pre></bdo></b><th id='4ZFiB'></th></span></q></dt></tr></i><div id='4ZFiB'><tfoot id='4ZFiB'></tfoot><dl id='4ZFiB'><fieldset id='4ZFiB'></fieldset></dl></div>

                          <bdo id='4ZFiB'></bdo><ul id='4ZFiB'></ul>
                          1. <small id='4ZFiB'></small><noframes id='4ZFiB'>

                            <legend id='4ZFiB'><style id='4ZFiB'><dir id='4ZFiB'><q id='4ZFiB'></q></dir></style></legend>