When my relationship delete rule is set to Nullify, will the inverse relationship also be deleted?

前端 未结 1 982
野趣味
野趣味 2020-12-29 16:34

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.

相关标签:
1条回答
  • 2020-12-29 17:33

    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.

    So:

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

    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
    

    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.

    0 讨论(0)
提交回复
热议问题