Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Database programmers use junction tables to implement m:n relations. (http://en.wikipedia.org/wiki/Junction_table.) Junction objects follow the same logic as junction tables. A junction object contains two object lists, one for the n-side, one for the m-side. Here is a sample for a junction object implementing an engagement, i.e. an m:n-relationship between movies and actors. (One actor is hired for more than one movie; one movie has more than one actor.) The junction object holds the data for a single actor's engagement: a reference to the actor and a reference to the movie. This roughly corresponds to a single record in a junction table. We use bidirectional relationships between both the Actor-Engagement relation and the Movie/Engagement relation. This means that both the Actor and the Movie class must have an object list with Engagements.

...