An Employee has an inverse relationship to it's Department and vice versa. The Employee entity has an Relationship called department, and it has a DENY delete rule. Employee shall be deleted. Now: Does DENY actually deny deletion of employee, because department is still referencing a Department? Or does it mean that a Department can't be deleted because an Employee is referencing it?
A delete rule defines what happens when the record that owns the relationship is deleted. A delete rule defines what happens when the record that owns the relationship is deleted. Select the notes relationship of the Category entity and open the Data Model Inspector on the right.
Setting the Delete Rule to Delete guarantees that when a record of the main Entity is deleted, all the associated records in the related Entities are also deleted.
One approach to delete everything and reset Core Data is to destroy the persistent store. Deleting and re-creating the persistent store will delete all objects in Core Data.
Deletion rules are always looked at from the point of view of the object they are being set on so I think you have your description backwards. What you would want in that situation is:
Employee can be deleted any time and it's relationship to it's department should be nullified. This means you set the department relationship to nullify.
Department can only be deleted if it no longer has any employees. This calls for a deny rule which would prevent the deletion of a department if it contains any employee records at all.
Your description implied the reverse which would mean that the employee could not be deleted unless it's department was set to nil. While certainly possible, it seems unnecessary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With