English 中文(简体)
核心数据关系设计
原标题:Core Data Relationship Design?

我对你如何在核心数据中建立关系有疑问。

我将举例说明:

我要说的是,我有3个实体。 • 机动、消耗和警报。

机动车和泵可以发出警告。

警报实体将储存所有来自摩托车和皮乌姆的警告。

因此,问题是...... 是否确实有必要建立如此多的摩托车和皮乌姆预警关系? 当我想增加另一个能够发出警告的实体时,我需要另一种关系。

这难道不是坏的设计吗?

希望我是可以理解的。

感谢。

最佳回答

是的,这是正常的。 一种更好、更有条理的办法是建立一个机动和消耗的基地实体,让它称作构成部分。 该构成部分实体与警报部门有关系,警报实体与构成部分有不正当的关系。

然后,你将你的摩托车和皮泵定为构成部分实体的后代,一切都很好。 构成部分和警告之间的单一关系/反向关系。

问题回答

This is standard and good practice. Core Data requires inverse relationships for everything to maintain its object graph. (Well, technically you don t have to add them, but you then have to do extra work yourself).

因此,你经常被利用的实体通常会对他们有多种不利关系,这并不令人担心。





相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签