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

    <tfoot id='yDNXj'></tfoot>
    1. <legend id='yDNXj'><style id='yDNXj'><dir id='yDNXj'><q id='yDNXj'></q></dir></style></legend>

          <bdo id='yDNXj'></bdo><ul id='yDNXj'></ul>

      1. <i id='yDNXj'><tr id='yDNXj'><dt id='yDNXj'><q id='yDNXj'><span id='yDNXj'><b id='yDNXj'><form id='yDNXj'><ins id='yDNXj'></ins><ul id='yDNXj'></ul><sub id='yDNXj'></sub></form><legend id='yDNXj'></legend><bdo id='yDNXj'><pre id='yDNXj'><center id='yDNXj'></center></pre></bdo></b><th id='yDNXj'></th></span></q></dt></tr></i><div id='yDNXj'><tfoot id='yDNXj'></tfoot><dl id='yDNXj'><fieldset id='yDNXj'></fieldset></dl></div>
      2. 在 SQL Server 中定义一对一关系

        时间:2023-10-10
            <bdo id='IEY72'></bdo><ul id='IEY72'></ul>

                  <tbody id='IEY72'></tbody>
                <legend id='IEY72'><style id='IEY72'><dir id='IEY72'><q id='IEY72'></q></dir></style></legend>

                <i id='IEY72'><tr id='IEY72'><dt id='IEY72'><q id='IEY72'><span id='IEY72'><b id='IEY72'><form id='IEY72'><ins id='IEY72'></ins><ul id='IEY72'></ul><sub id='IEY72'></sub></form><legend id='IEY72'></legend><bdo id='IEY72'><pre id='IEY72'><center id='IEY72'></center></pre></bdo></b><th id='IEY72'></th></span></q></dt></tr></i><div id='IEY72'><tfoot id='IEY72'></tfoot><dl id='IEY72'><fieldset id='IEY72'></fieldset></dl></div>
                <tfoot id='IEY72'></tfoot>
              1. <small id='IEY72'></small><noframes id='IEY72'>

                  本文介绍了在 SQL Server 中定义一对一关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要定义一对一的关系,但在 SQL Server 中似乎找不到正确的方法.

                  你问为什么是一对一的关系?

                  我使用 WCF 作为 DAL (Linq) 并且我有一个包含 BLOB 列的表.BLOB 几乎不会改变,每次进行查询时都将其传输过来会浪费带宽.

                  我查看了

                  创建表组织(ID int PRIMARY KEY,名称 varchar(200),地址 varchar(200),电话 varchar(12))走创建表客户(ID int PRIMARY KEY,AccountManager varchar(100))走ALTER TABLE 客户添加外键 (ID) 引用 组织 (ID)删除级联更新级联走

                  I need to define a one-to-one relationship, and can't seem to find the proper way of doing it in SQL Server.

                  Why a one-to-one relationship you ask?

                  I am using WCF as a DAL (Linq) and I have a table containing a BLOB column. The BLOB hardly ever changes and it would be a waste of bandwidth to transfer it across every time a query is made.

                  I had a look at this solution, and though it seems like a great idea, I can just see Linq having a little hissy fit when trying to implement this approach.

                  Any ideas?

                  解决方案

                  One-to-one is actually frequently used in super-type/subtype relationship. In the child table, the primary key also serves as the foreign key to the parent table. Here is an example:

                  CREATE TABLE Organization
                  ( 
                       ID       int PRIMARY KEY,
                       Name     varchar(200),
                       Address  varchar(200),
                       Phone    varchar(12)
                  )
                  GO
                  
                  CREATE TABLE Customer
                  ( 
                       ID              int PRIMARY KEY,
                       AccountManager  varchar(100)
                  )
                  GO
                  
                  ALTER TABLE Customer
                      ADD  FOREIGN KEY (ID) REFERENCES Organization(ID)
                          ON DELETE CASCADE
                          ON UPDATE CASCADE
                  GO
                  

                  这篇关于在 SQL Server 中定义一对一关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 Contains() 时达到 2100 参数限制 (SQL Server) 下一篇:如何在 Express 4 Web 应用程序中跨多个路由使用单个 mssql 连接池?

                  相关文章

                  <tfoot id='C08y9'></tfoot>

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

                  1. <small id='C08y9'></small><noframes id='C08y9'>

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