core data - Deletions in a many-to-many structure -


i want check quickly. have 2 entities in data model: catalog, , product. have many-to-many relationship each other, , both required (a catalog must have @ least 1 product, , products must each belong @ least 1 catalog). if delete product, deletion should nullify, of course.

but should deletion policy catalog? if catalog deleted, not of products exclusively belong it. product may belong more 1 catalog. shouldn't use cascade. however, nullify sufficient? if end dangling products don't belong catalog? core data have built in resolve issue many-to-many schemas? need modify schema?

nullify sufficient, , many-to-many sounds right. specific constraint want (deleting orphans) not directly enforceable core data, though, little cleanup yourself.

specifically, implement willsave in entity classes, , have each entity test: not deleted; and, have no associated (products/catalogs)? if so, delete myself. (the not-deleted test important avoid infinite loop of willsaves.)

this postpones deletion of orphaned catalogs or products until save time. not problem.


Comments

Popular posts from this blog

jQuery clickable div with working mailto link inside -

WPF: binding viewmodel property of type DateTime to Calendar inside ItemsControl -

java - Getting corefrences with Standard corenlp package -