当我的关系删除规则设置为Nullify时,反向关系也会被删除? [英] When my relationship delete rule is set to Nullify, will the inverse relationship also be deleted?

查看:95
本文介绍了当我的关系删除规则设置为Nullify时,反向关系也会被删除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例:我有一个部门和一个员工。部门对许多员工具有Nullify关系,而员工与一个部门具有相反的关系。

Example: I have a Department and an Employee. Department has a Nullify relationship to many Employees, and an Employee has an inverse relationship to one Department.

现在我删除与员工的关系。所以让我们说营销部门不再链接到史蒂文斯了。

Now I remove the relationship to an Employee. So lets say the Marketing Department doesn't link anymore to Joe Stevens.

1)当请求他的部门时,史蒂文斯仍然链接到营销部门吗?或者Core数据是否自动处理这个问题,并且无效?

1) Does Joe Stevens still link to the Marketing Department, when asking for his Department? Or is Core Data handling this automatically and also "nullifying" that?

2)在Employee一侧指定了哪个删除规则是否重要?让我们说是Cascade。部门取消了与员工的关系。我相信在这种情况下,Employee的删除规则是不相关的。

2) Does it matter which delete rule is specified on the side of the Employee? Let's say that was Cascade. The Department removed the relationship to the Employee. I believe the delete rule of the Employee is not relevant in this case, right?

推荐答案

删除规则控制对象在保存规则本身的对象被删除时的关系的另一端。

The delete rule govern what happens to the object at the other end of the relationship when the object holding the rule itself is deleted.

所以:

A<-(cascade)->>B
B<<-(nullify)->A

导致所有相关B的删除。然而,删除任何单个B只会使A忘记该特定的B.

Deleting A causes the deletion of all related B. However, deleting any single one B simply causes A to forget about that particular B.

因此,删除规则总是与对象,因为目标对象是删除规则的整个点。当对象有多个关系时尤其如此。

So, the delete rule is always relevant to the object it is targeted at because the targeted object is the entire point of the delete rule. This is especially true when objects have multiple relationships.

A<-(cascade)->>B
B<<-(nullify)->A
C<--(cascade,required)-->>B

C对象将阻止任何B对象的级联删除,它也保持,无论A想要什么。 (在这种情况下,A将会被取消。)

The C object will block the cascade deletion of any B objects it also holds regardless of what A wants. (A will nullify in that case.)

你不应该在实际编程方面考虑删除规则,而是根据你试图建模的真实世界系统。考虑真实系统的关系,然后设置删除规则来模仿那些。在这种情况下,我们将模仿公司的实际组织规则。

You should not think of delete rules in terms of actual programming but rather in terms of the real world system you are trying to model. Think about the relationship of the real system and then set the delete rules to mimic those. In this case we would mimic the actually organizational rules of the company.

这篇关于当我的关系删除规则设置为Nullify时,反向关系也会被删除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆