5. Richer Associations

Yes, wealthy friends would be nice. But I can't propose an easy way to get any, so let's look at relationships between objects that carry more information than simple grouping. In this chapter we'll look at the tracks that make up an album. We had put that off in Chapter 4 because organizing an album involves more than simply grouping some tracks; you also need to know the order in which the tracks occur, as well as things like which disc they're on, in order to support multi-disc albums. That goes beyond what you can achieve with an automatically generated join table, so we'll design our own AlbumTrack object and table, and let albums link to these.

Before diving in, there's an important concept called "laziness" we need to explore.

In this chapter:

  • Using Lazy Associations

  • Ordered Collections

  • Augmenting Associations in Collections

  • Lifecycle Associations

  • Reflexive Associations

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset