Object Relationships

Objects can have relationships to other objects

Relationships

An Object in Logiak is defined by its name and its fields, but also its _relationships- with other objects.

Relationship example

Let us think of an example to illustrate.

Suppose we have a customer Object which has three fields: name, company and email, and you bill customers by sending them invoices. Each invoice applies to a customer therefore, and any customer “has” zero or more invoices which apply to them.

 
  
  erDiagram
    CUSTOMER ||--o{ INVOICE : has
    CUSTOMER {
        text uuid
        text name
        text company
        text email
    }
    INVOICE {
        text uuid
        date invoice_date
        number amount
        boolean paid
    }
    
         

Same example in Logiak

In Logiak, the fact that each invoice has a customer is represented explicitly in the definition of invoice, like this:

This video shows how customer and invoice are configured:

Example of defining a relationship

Relationship values

Relationships are represented by fields at the database level, so in the above example, when looking at the data in your backend, you would see a “customer” column in the invoice table/structure.

As with traditional databases, the value of that field will be the value of the Unique Field of the customer object to which the invoice belongs.