Bartłomiej Semańczyk
Bartłomiej Semańczyk

Reputation: 61880

Cascade delete rules in `many to many` relationships in Core Data

I have 2 entities: CD and Song.

CD1 has songs: Song1 and Song2.
CD2 has songs: Song1.
CD3 has songs: Song3.

Relationships:

CD <<-->> Song (many to many)
CD may have a lot of Songs, and one Song may belong to a few CD's.

Delete rules for CD: Cascade to Song
Delete rules for Song: Nullify CD

What happens If I:

remove CD1: will remove Song2, what about Song1?
remove CD2: will remove Song1?
remove CD3: will remove Song3

Upvotes: 4

Views: 474

Answers (1)

Peter Zhou
Peter Zhou

Reputation: 4251

CD1 has songs: Song1 and Song2. CD2 has songs: Song1.

Looks like the relationship between CDs and Songs should be many to many.

Answer to your question:

When CD1 is removed Song1 will be removed, regardless of CD2.

Upvotes: 5

Related Questions