菜鸟教程小白 发表于 2022-12-12 21:36:34

ios - 抽象实体上的核心数据关系


                                            <p><p>当一个实体设置为抽象时,在两个实体之间创建一对一关系是否合法?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>抽象实体并不意味着被实例化。这就是为什么您<strike><strong>不能</strong></strike>建立这样的关系。但是,您可以做的是创建一个实体从抽象实体继承的关系。</p>

<p>来自 <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdRelationships.html#//apple_ref/doc/uid/TP40001857-CJBDBHCB" rel="noreferrer noopener nofollow">Apple&#39;s docs</a> :</p>

<blockquote>
<p>A relationship specifies the entity, or the parent entity, of the
objects at the destination. This can be the same as the entity at the
source (a reflexive relationship). Relationships do not have to be
homogeneous. If the Employee entity has two sub-entities, say Manager
and Flunky, then a given department&#39;s employees may be made up of
Employees (<strong>assuming Employee is not an abstract entity</strong>), Managers,
Flunkies, or any combination thereof.</p>
</blockquote>

<p><strong>编辑:</strong>
显然你可以创建这样的关系(这样子实体也可以继承关系)......</p>

<blockquote>
<p>If you define an entity inheritance hierarchy (see “Entity
Inheritance”), when you specify a super-entity as the entity for a
fetch request, the request returns all matching instances of the
super-entity and of sub-entities. In some applications, you might
specify a super-entity as being abstract (see “Abstract Entities”). To
fetch matching instances of all concrete sub-entities of the abstract
entity, you set the entity for fetch specification to be the abstract
entity. In the case of the domain described in “Abstract Entities,” if
you specify a fetch request with the Graphic entity, the fetch returns
matching instances of Circle, TextArea, and Line.</p>
</blockquote>

<p>另请参阅此答案:<a href="https://stackoverflow.com/questions/6327835/core-data-abstract-entity-in-fetch-request" rel="noreferrer noopener nofollow">Core Data: Abstract Entity in Fetch Request</a> </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 抽象实体上的核心数据关系,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/11192497/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/11192497/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 抽象实体上的核心数据关系