Different Relationship Types in Akwatype: One-to-One, One-to-Many, Many-to-Many

Relationship Types in Akwatype: One-to-One, One-to-Many, Many-to-Many

Relationships between types are essential for modeling interactions and links within a business domain. They help structure the model by defining how each entity is connected to the others, whether through individual or group relationships. Akwatype offers several types of relationships to model these links flexibly and efficiently: one-to-one, one-to-many, and many-to-many. This page examines each of these relationships and explains how to use them to build robust, clear data models.

To discover our various concepts, click here!


One-to-One Relationship

The one-to-one relationship indicates that an instance of one type is linked to a single instance of another type. This relationship is used when the two entities are so closely connected that they almost form a single logical unit in the data model.

  • Example of a One-to-One Relationship: A piece of contact information can be associated with a single address. In this case, each piece of contact information is associated with one address, and each address is specific to one piece of contact information

    ContactInfo { address: Address { label: "Contact address" minItems: 1 } }

 

One-to-one relationships are often used to divide complex information into subgroups while maintaining a strong link between entities.


One-to-Many Relationship

The one-to-many relationship indicates that an instance of one type can be linked to several instances of another type, but each instance of the other type is linked to a single instance of the original entity. This structure is ideal for representing links where a central element has several sub-elements.

  • Example of a One-to-Many Relationship: A product can only be supplied by one supplier, but each supplier can supply multiple products.
plaintextProduct {
  supplier: Supplier {
    label: "Supplier providing this product"
    reverse: products
  }
}

Supplier {
  products: [Product] {
    label: "Products supplied by the supplier"
  }
}

If you want the relationship to be bi-directional, the reverse property indicates the inverse relationship of the products attribute on the Supplier type.

One-to-many relationships are among the most common in data models, as they enable hierarchies and groupings to be structured around central entities.


One-to-many relationship

The one-to-many relationship indicates that an instance of one type can be linked to several instances of another type, but each instance of the other type is linked to a single instance of the original entity. This structure is ideal for representing links where a central element has several sub-elements.

  • Example of a one-to-many relationship: A product can only be supplied by one Supplier, but each Supplier can supply multiple Products. In this case, a Supplier can be associated with a collection of Products, but a Product belongs to only one Supplier.

  • Use in Akwatype: Akwatype lets you configure one-to-many relationships by defining which attribute is a list in the relationship.

    • A Product to a Supplier (supplier : Supplier

Product {

    supplier: Supplier {

        label: "Supplier who provide this product"

        reverse: products

    }

 

If you want the relationship to be bi-directional, reverse indicates that it is the inverse relationship of the products attribute on the Supplier Type. The reverse property is only indicated on one side of an association.

  • A Supplier supplies several Products (products: [ Product ]),
    [ ] indicates a list of the type in square brackets.

Supplier {

    products:[Product]{

        label: "Products supplied by the supplier"

    }

 


 


One-to-many relationships are among the most common in data models, as they enable hierarchies and groupings to be structured around central entities.

 


 

Many-to-many relationship

The many-to-many relationship is used when an instance of one type can be associated with several instances of another type, and vice versa. This relationship models links where two entities can share several reciprocal associations, offering great flexibility for complex structures.

  • Example of a many-to-many relationship: A product can be supplied by multiple Suppliers, and each Supplier can supply multiple Products. In this case, a Supplier can be associated with a collection of Products, and a Product with a collection of Suppliers.

 

  • Use in Akwatype: In Akwatype, the many-to-many relationship can be managed in two ways. 

    • Or directly with a list attribute on each entity pointing to the other entity.

      • A Product with several Suppliers (supplier : [ Supplier]

Product {

    supplier: [Supplier] {

        label: "Suppliers who provide this product"

        reverse: products

    }

 

reverse indicates the inverse relationship of the products attribute on the Type Supplier

  • A Supplier with several Products (products: [ Product ]),
    [ ] indicates a list of the type in square brackets.

Supplier {

    products:[Product]{

        label: "Products supplied by the supplier"

    }

 

 

  • Or by using a junction or association type, which centralizes the connections between the two types and adds attributes to the relationship. 
    For example, a Replenishment type ensures the link between Products and Suppliers, by managing the minimum quantity and the replenishment lead time for each Supplier concerning each Product.




Many-to-many relationships are particularly useful for representing networks of links in complex models, where multiple entities are interdependent.

 


 

Conclusion

The one-to-one, one-to-many and many-to-many relationship types make it possible to model a wide variety of connections between entities in Akwatype. By using these relationships with precision and adapting cardinalities to business requirements, teams can create robust, intuitive data models ready for use in complex environments.

 

Model your data as early as possible
for effective design.

Structure your data modeling from the start of your projects to communicate, describe your workflows, and empower your development teams.