| 40 | === Create a relationship === |
| 41 | |
| 42 | In the relationship browser, select the ''Artist'' class and click on the relationship symbol: --> |
| 43 | |
| 44 | In the category menu, select ''OneToMany''. As you can see, there is a template for a ''OneToManyRelationship'' in the edit pane. Simply add the ''Artwork'' class as the right class and save. The new relationship has been created. |
| 45 | |
| 46 | If you go back to the instance view, you can see that ''Artist'' does now have the methods ''addArtwork:'', ''artworks'' and ''removeArtwork''. ''Artwork'' has the method ''artist''. |
| 47 | |
| 48 | === Edit a relationship === |
| 49 | |
| 50 | Assume we have found out that sometimes, multiple artists collaborate to create an artwork. |
| 51 | |
| 52 | Go back to the relationship view (use -->) and select the existing relationship. The edit pane is filled with the previous values. To create a many to many relationship, replace ''OneToManyRelationship'' with ''ManyToManyRelationship''. Hit save and look at the newly generated methods. |
| 53 | |
| 54 | Assume all artworks in this relationships are paintings. We don't want to create a new subclass for this, but change the name used in the methods. |
| 55 | |
| 56 | Select the existing relationship and add a name for the right class: ''rightClassName: 'painting' '' and save. The methods will be renamed. |
| 57 | |
| 58 | = Known limitations = |
| 59 | |
| 60 | The relationships are not added to monticello when saved (however, the generated methods and instance variables are - your code still works). |