Skip to main content

relationship

Definition

A relationship in VKL describes how classes relate to each other.

Example:

  • Till_Haug works at Veezoo_AG
  • JP_Monteiro is from the segment Consumer
  • Rio_de_Janeiro is located in Brazil

In other words, we have the following relationships:

  • works_at is a relationship that goes from Employee to Company
  • from_segment is a relationship that goes from Customer to the class Segment
  • located_in is a relationship that goes from City to the class Country

Usage

import: [
db.postgres.movie_db.public.CUSTOMER
]

kb {

class Customer {
...

relationship lives_in {

/** How to display this relationship to the user in an answer's filters,
* e.g. "Customer lives in Brazil"
* Default: "with" */
display_name.en: "lives in"

/** Specifies the cardinality of the relationship
* one of: KB_One2One, KB_Many2One, KB_Many2Many, KB_One2Many).
* Default: KB_Many2One */
tag: KB_Many2One

/** lives_in is a relationship that goes from Customer to Country. */
to: kb.Country

/** An optional join path in the case of intermediate tables.
* Default: not set */
join: [ ... ]

/** The sql expression representing this relationship. */
sql: "${CUSTOMER.country_id}"
}
}
}
PropertyOptional/MandatorySummaryDefault
toMandatoryA relationship is always between the outer class where it is defined and another class, specified in the property to.No default
sqlMandatoryThe sql expression representing this relationship, usually a foreign key.No default
display_nameOptionalHow to display this relationship to the user in an answer's filters, e.g. "Customer lives in Brazil"with" in the respective language
tag: KB_Many2One/etcOptionalSpecifies the cardinality of the relationship, one of: KB_One2One, KB_Many2One, KB_Many2Many, KB_One2Many).KB_Many2One
joinOptionalAn optional join path in the case of intermediate tables.Not set
to_nameOptionalA name for the class defined in to, e.g. to distinguish Origin Airport and Departing Airport in answers.No default
to_synonymOptionalA synonym for the class defined in to, e.g. Origin Airport can have a synonym 'Departing Airport'.No default