Basics: Relationships Cardinality

thumbnail

on May 18, 2022 • Back to Blog index

Relationship cardinality is a key concept allowing you to set the basic behavior of a relationship. It is part of these small technical aspects in configuration management which you need to understand before going into your datamodel design.

What is a Relationship and why sometimes you call them properties

A relationship describes a connection between two nodes. Even if Ganister allows undirected relationships (we will cover that in a later blog post), technically, relationships describe a connection between a source node and a target node. Relationships can be used in different context. If you look at a physical product, every sub component is physically present in this specific physical product (and can't be elsewhere). If you look at the same structure but in the design phase, each sub component definition can be included in one or multiple products.

Relationship seen as properties

Quite often we want properties that actually represent relationships. If you have a Customer Order, you will have a property for the customer reference. If this is a string representing the customer name, you will be in trouble the day the customer name changes. In classic databases design, you would have an ID representing the customer. In Ganister we threat it as what it really is => a relationship. Even if you see it as a property, the graph will record two nodes and a relationship.

Now, let's check the existing options we have and how they translate into a user experience in Ganister.

Possible Cardinalities


N to N

Ganister Grid

The N to N relationship is the most current. It means:

  • A source can have multiple targets
  • each target can have multiple sources

The typical use case is an engineering bill of material. Any assembly can consume multiple parts and each part can be consumed by multiple assemblies. You could also find this in a part to document relationship if the related documents can be documenting various parts.

Consequences in Ganister

In Ganister, the consequence is that you will only be able to map it to a tab (or just not map this relationship to some user interface) but you will not be able to assign this relationship to a property.


1 to N

Ganister Grid

The 1 to N relationship is used when you need to create a list of nodes only attached to a single source. It means:

  • A source can have multiple targets
  • each target can have only one source

Consequences in Ganister

The 1 to N relationship is generally handled in a tab where each relationship occurrence is represented by a line in a table. Targets being only attached to a single source we could decide if targets need to be removed when the source is removed. In the case of a shopping list it makes sense. In some other context we might want to keep the targets and allow them to be disconnected before being reconnected to a single source.


N to 1

Ganister Grid The N to 1 relationship is used when the source needs a relationship to a single target, but this target could be used in other sources. It means:

  • A source can have only one source
  • each target can have multiple targets

Consequences in Ganister

The consequence is that Ganister will not allow to map this relationship to a tab. A tab is by design built to manage multiple targets. The only UI you will be able to set is a node input in a form (and/or a table).


1 to 1

Ganister Grid The 1 to 1 relationship is not very usual. It really means you attach two nodes on a specific relationship and once attached these nodes cannot be atttached to other nodes through this type of relationship. The reason being it is usually a split of a larger object to allow different permissions and rights on different type of data.


Free (Ganister's special)

Free relationship is just by default behaving like N to N but we don't restrict any usage (tab or form). It is convenient when you are not sure about cardinality.

Conclusion

Even for a nocode or lowcode platform, you still need to understand how your relationships behave in order to adapt the data recording, but also a coherent user experience. Of course if you are lost with it you can use the free mode but you will miss some of the great data fetching capabilities using our underlying Graph Database.


Yoann Maingon
Co-Founder & CEO of Ganister