relationship
Definition
A relationship in VKL describes how classes relate to each other.
Example:
Till_Haug
works atVeezoo_AG
JP_Monteiro
is from the segmentConsumer
Rio_de_Janeiro
is located inBrazil
In other words, we have the following relationships:
works_at
is a relationship that goes fromEmployee
toCompany
from_segment
is a relationship that goes fromCustomer
to the classSegment
located_in
is a relationship that goes fromCity
to the classCountry
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}"
}
}
}
Property | Optional/Mandatory | Summary | Default |
---|---|---|---|
to | Mandatory | A relationship is always between the outer class where it is defined and another class, specified in the property to . | No default |
sql | Mandatory | The sql expression representing this relationship, usually a foreign key. | No default |
display_name | Optional | How 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/etc | Optional | Specifies the cardinality of the relationship, one of: KB_One2One, KB_Many2One, KB_Many2Many, KB_One2Many). | KB_Many2One |
join | Optional | An optional join path in the case of intermediate tables. | Not set |
to_name | Optional | A name for the class defined in to , e.g. to distinguish Origin Airport and Departing Airport in answers. | No default |
to_synonym | Optional | A synonym for the class defined in to , e.g. Origin Airport can have a synonym 'Departing Airport'. | No default |