Make a many-to-many association
Goal
- Add a many-to-many association such that
- each
User object has many BlogPost objects,
- each
BlogPost object has many User objects, and
- the association has an association class,
Favorite.
Steps
- Add
Favorite class:
- Add the association declaration:
- Add
User - BlogPost to specify a new association between the User and BlogPost classes.
- Add
"user *" on the User side to specify a multiplicity of * and a role name of user.
- Add
"post *" on the BlogPost side to specify a multiplicity of * and a role name of post.
- Add the association class declaration:
- Add
(User, BlogPost) to specify that the association class will be on the preceding association between these classes.
- Add
.. Favorite on the end of the declaration to specify that the Favorite class will be the association class.
Reference Code
- Many-to-many association code: