核心数据:抽象实体和继承关系

发布于 2024-08-05 06:37:30 字数 652 浏览 1 评论 0原文

我的确切模型很难解释,所以假设我正在 Xcode 的核心数据建模器中对水果及其种子进行建模。这是一些“伪核心数据代码”:

abstractEntity Fruit
attribute sweetness
relationship Seed

abstractEntity Seed
attribute shape

concreteEntity Apple inherits Fruit
concreteEntity Orange inherits Fruit

concreteEntity AppleSeed inherits Seed
concreteEntity OrangeSeed inherits Seed

我以这种方式建模的原因是我希望能够获取水果的混合物并按种子形状对它们进行排序。给定这个模型,我的问题是:

Xcode 建模器(即从 GUI)中是否有任何直接方法可以让我指定 Apple 只能有 AppleSeeds 而 Oranges 只能有 OrangeSeeds?在上面的模型中,具体水果继承了抽象的种子关系,我需要它来获取和排序混合的水果/种子,但我没有看到任何方法来强制执行每个具体水果必须具有的确切种子关系。

我看到有很多不同的方法可以在建模 GUI 之外强制执行此操作,但只是想确保我没有遗漏某些内容。有什么建议吗?

希望这个例子有意义!

My exact model is complicated to explain, so say that I'm modeling fruits and their seeds in Xcode's Core Data modeler. Here's some "pseudo Core Data code":

abstractEntity Fruit
attribute sweetness
relationship Seed

abstractEntity Seed
attribute shape

concreteEntity Apple inherits Fruit
concreteEntity Orange inherits Fruit

concreteEntity AppleSeed inherits Seed
concreteEntity OrangeSeed inherits Seed

The reason I modeled in this way is that I want to be able to fetch a mix of fruits and sort them by their seed shapes. Given this model, here's my question:

Is there any direct way in the Xcode modeler (i.e., from the GUI) that will enable me to specify that Apples can only have AppleSeeds and Oranges can only have OrangeSeeds? In the model above, concrete fruits inherit an abstract Seed relationship, which I need in order to fetch and sort mixed fruits/seeds, but I don't see any way to enforce the exact Seed relationship that each concrete fruit must have.

I see lots of different ways to enforce this outside of the modeling GUI, but just want to make sure I'm not missing something. Any suggestions?

Hopefully this example makes sense!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半﹌身腐败 2024-08-12 06:37:30

我能想到的唯一方法是从超实体中删除种子关系,并将特定的 AppleSeed 和 OrangeSeed 关系放入子实体中。您也许能够覆盖子实体中的关系,而无需将其从超实体中删除,但据我所知,模型编辑器中无法执行您所描述的操作。

The only way I can think of is to remove the seed relationship from the superentity and put specific AppleSeed and OrangeSeed relationships in the subentities. You may be able to override the relationship in the subentities without removing it from the superentity but as far as I know there's no way in the model editor to do what you're describing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文