6

is there somebody who can explain the usage of the relationship strength "Composition" in QGIS 3? What can the user do in detail when setting to "Composition"?

Relationship strength sets the strength of the relation between the parent and the child layer. The default Association type means that the parent layer is simply linked to the child one while the Composition type allows you to duplicate also the child features when duplicating the parent ones.

This is only a short description. I checked out to copy and paste a polygon feature with a relation to a point feature (relationship strength "Composition"). Failed.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
geofee
  • 631
  • 1
  • 5
  • 10

2 Answers2

5

I think you can find answers to this in the data modelling and database literature. In UML, a composition is a specialisation of an association (introducing constraints).

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-aggregation-vs-composition/ explains it like this:

Composition implies a relationship where the child cannot exist independent of the parent. Example: House (parent) and Room (child). Rooms don't exist separate to a House.

Since a child object can't exists without the parent object, it will be deleted if the parent object is deleted. To dive deeper, you could try to search for "relationship composition association".

I have not looked into how this is implemented in QGIS, but since this terminology is used, I would assume that the object-oriented modelling "rules" are followed.

Håvard Tveite
  • 3,256
  • 17
  • 32
1

This will tell QGIS how children will be handled, when parents are duplicated/deleted.

With association, children are ignored. With composition, children are also duplicated/deleted.

Matthias Kuhn
  • 27,780
  • 3
  • 88
  • 129