Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 503
Bartłomiej Semańczyk Avatar asked Oct 17 '25 14:10

Bartłomiej Semańczyk


1 Answers

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.

like image 151
Peter Zhou Avatar answered Oct 20 '25 04:10

Peter Zhou



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!