The composition relation is represented by an arrow from the "host" class with a colored diamond (from black) to the "part" class (with no symbol at this end, but at most specifying the total number of that part).
For example, it assumes having a Pessoa
class, and, as we well know, a person is "made up" by legs and arms. Here you could create a composition relation from the Pessoa
class with a colored diamond to the Perna
and Braço
class.
Notethatyoucouldhavespecifiednumber2atthePerna
andBraço
ends,becausefortunatelymostpeoplehave2armsandlegs.
Inyourfirstspecificcase,onthesecondarrowthediamondshouldbeonthepartoftheC
class,sinceyouwantC
asthewhole(orthe"host" class).
In general, you can have the combinations of relationships that you like. Clearly some have more sense than others. Even though your second diagram does not represent what you would like to get, because you say you want a "composition" between A
and B
, but in reality when you use an empty diamond it means "aggregation". Most probably you've traded the two relationships.
There are good articles online to understand more about these relationships:
Among many others.