Skip to content

Relations

What is a Relationship and their role in the data model?

Section titled “What is a Relationship and their role in the data model?”

A Relation its a logical link between records, is the way of saying some record X has something to do with record Y, the way they are related and what that relation represents depends on the configurator user, but the most common use cases is to express parent to child relationships or categorization with atomic records.

Examples:

  • A Product record related to a Category record to express something like a Product Shoes has a relation Category assigned to the Category record Garment
  • A list of Item record related to an Invoice record, to express items being sold in a particular transaction, like Invoice 1 having 10 Black Shoes Items

To summarize its the way of relating atomic units of data together based on their nature, to keep track of the interactions your particular data model requires

The relationships you can create in DatAscend are named after the types on relational database

To express that a given entity record can only have one possible value for the related entity record, and in the same way, that related entity record cannot be referenced in this same relationship by a different entity record.

  • Example: A Product can only have 1 Owner, and that Owner is not allowed to own more than one Product

To express that a given entity record can have multiple related records from a different entity.

  • Example: A Car entity can have many Parts records, like each Part entity record being: heated seats, airbags, etc…

This is the most common relation, its basically the inverse of the One To Many, its a way of saying that multiple records of a given entity can all be related to the same record in a related Entity.

  • Example: Many Students entity records can be assigned to the same School record.

This is the most abstract relation we support, and its the most versatile one, used to express that many records of a given entity record can be related to many records of a related entity. Used most of all to related reusable non uniquely owned entities between each other.

  • Example: Many Students entity records can be assigned to many Courses records, and in the same way, each Courses record will have many students related.
  1. The place to create, edit or generally manipulate Relations is the Studio. To enter it you can simply click the Studio navigation item on the header of the page.

Note:

  • You need to be assigned to an Administrator role in order to see or even access the Studio
  • If you are on the welcome page, you can also click the Studio card
Dashboard image with the Studio header navigation item hovered
  1. Once on the Studio click on the Entity wether in the left side bar that lists them, or the card in the canvas, that will show the details drawer
Studio image with the details drawer
  1. On the details drawer, focus on the Relations section and click the + Add new relation button, which will show the Add Relation modal
Studio image with the add relations modal visible
  1. In here you can create a new relationship, the constrols will change a little based on the relation type you want to create, but here we will explain what every field is for:

    • The attribute on the Entity to use as a reference for the relation, there are two possible cases in here:
      • a. The relation type is One To One or Many To One: The input will be a text field, where you can write the property where the related reference value will be stored in the entity record
      • b. The relation type is One To Many or Many To Many: The input will be a dropdown field, where you have to pick the existing attribute on the entity, that the related entity will be referencing
    • The sanitized name this relation will have on the main entity, used to perform updates to the relations
    • The human friendly name you can give to this relation, it will be displayed when interacting with their records
    • In the case of a direct dependency between relations, you can select a second relation in the main entity, that this new relation will depend on, more on dependeny in Dependency

    • The related Entity on the other end of this relationship
    • The attribute on the Related Entity to use as a reference for the relation, there are two possible cases in here:
      • a. The relation type is One To One,Many To One or Many To Many: The input will be a dropdown field, where you have to pick the existing attribute on the related entity, that the main entity will be referencing
      • b. The relation type is One To Many: The input will be a text field, where you can write the property where the main entity reference value will be stored in the related entity record
    • The sanitized name this relation will have on the related entity, used to perform updates to the relations
    • The human friendly name you can give to this relation, it will be displayed when interacting with their records of the related entity
    • In the case of a direct dependency between relations, you can select a second relation in the related entity, that this new relation will depend on, more on dependeny in Dependency
  2. Confirm the changes and then click save on the details drawer to create the relationship

There are cases when some ralations possible values depends on another relation current value, we call these scenarios Dependency or Dependency Relations. The easiest way to ilustrate it is with some examples:

  • For the entities Animal, Animal Type, Animal Breed related in the following way
    • Animal Breed has a relation with Animal Type
    • Animal has a relation with Animal Type and one in Animal Breed with a Dependency on Animal Type where the Animal Breed’s type matches the values on the type
  • And the following records
    • Animal Type -> Dog
    • Animal Type -> Cat
    • Animal Breed -> Persian, with type Cat
    • Animal Breed -> Bulldog, with type Dog
  • When creating a new Animal the user picks the type as Dog, the options for Animal Breed should be filtered out based on that value, so only “Bulldog”, would be available
  • In constrast, when the user picks the type as Cat, the options would be “Persian”

NOTE: Dependency relations are currently not enforced on Many to Many relations

How to view existing relationships for an entity?

Section titled “How to view existing relationships for an entity?”
  1. The place to view, edit or generally manipulate Relations is the Studio. To enter it you can simply click the Studio navigation item on the header of the page.

    Dashboard image with the Studio header navigation item hovered
  2. Once on the Studio click on the Entity wether in the left side bar that lists them, or the card in the canvas, that will show the details drawer, clicking on an existing relation dropdown at the end will display the actions, to view the current state of the relation, click the Edit Relation

Studio image with the details drawer hovering the Edit Relation action Studio image with the edit relation modal with values assigned
  1. The place to view, edit or generally manipulate Relations is the Studio. To enter it you can simply click the Studio navigation item on the header of the page.

    Dashboard image with the Studio header navigation item hovered
  2. Once on the Studio click on the Entity wether in the left side bar that lists them, or the card in the canvas, that will show the details drawer, clicking on an existing relation dropdown at the end will display the actions, to view the current state of the relation, click the Delete Relation

Studio image with the details drawer hovering the Edit Relation action
  1. Confirm the changes and then click save on the details drawer to delete the relationship
Section titled “How to use the UI to navigate between related entities”

On the details drawer in the Studio, you can see the Relations section, and each row has a column Entity that its in itself a link to that entities details drawer, clicking it will select that other entity and its attributes and relations. This way you can traverse the whole relation graph just with clicks

Studio image with relations section focused

Delete entities can also be done from the studio, entering the details drawer, there will be a button on top right corner, with a trash can icon

Delete entity button with a trashcan icon

Confirm the deletion of the entity to complete

Delete entity confirmation modal

Best practices and common mistakes to avoid

Section titled “Best practices and common mistakes to avoid”

Currently we don’t support circular references, having entities related to itself its discouraged as we don’t officially support it