onto.ID
Definition
onto.ID is used on attributes that model IDs that users might know and ask about, for example an ID assigned to each employee of the company.
Other examples are a policy number of policies of an insurance, or an internal database ID that might be interesting to more technical users.
Usage
An attribute is marked as ID by setting extends: onto.ID, which tells Veezoo to enable some special behavior.
In particular, when a user asks something like "Customers of Employee E1234-5678", Veezoo resolves "E1234-5678" to a filter on this attribute (ID = 'E1234-5678') if there isn't already an entity for "E1234-5678".
Supporting this kind of questions is especially useful for big classes, where it is difficult to synchronize all IDs as entities.
File: hitchhiker/knowledge-base/classes/Order.vkl
import db.postgres.movie_db.public.ORDERS
kb {
class Order {
from_table: ORDERS
sql: "${ORDERS.ID}"
/* ... */
// ID attributes work best as strings, but can also be classes (see below)
string ID {
name.en: "Order ID"
synonym.en: "ID"
// Tells Veezoo that an ID is unique to an order,
// i.e. different orders will have different IDs
tag: KB_One2One
// Often the same as the sql of the class (see class Order),
// but can be different if the internal DB ID is not the one users know about
sql: "${ORDERS.ID}"
// Marks this attribute as an ID, enabling special behavior
extends: onto.ID
}
}
}IDs are usually attributes of type 'string', but can also be of type 'class', which helps users with autocomplete and avoids treating unrelated text in a question as an ID. However, the ID entities can easily become out of date if not synchronized frequently, and there can be performance issues if there are too many of them, so IDs should only be classes if there aren't too many and they rarely change.