Skip to main content

subclass

Definition

A subclass designates a subset of a class with some special property. Subclasses in Veezoo are similar to subclassing (and inheritance) in object-oriented programming, but for your data.

Some typical examples of subclasses are:

  • Company Customer as a subclass of Customer
  • Cancellation as a subclass of Transaction (with a transaction being any change of a contract like an insurance policy)
  • Phone Call as a subclass of Customer Contact

A subclass is defined by a filter on the class that holds for all subclass instances using VQL (Veezoo Query Language). It shares the attributes of its parent class, but can also have its own attributes.

Usage

The main purpose is to group related attributes together that only make sense for a subset of data. For example, a CUSTOMER table can contain both private and company customers. But there may be columns that are only relevant for private customers (e.g. BIRTHDATE), while others are only relevant for company customers (e.g. COMPANY_SIZE, INDUSTRY).

A good subclass definition helps Veezoo understand questions better by excluding nonsensical interpretations of a question, groups related attributes together so that users can more easily understand the data and makes autocomplete more precise.

Now, let's have a look at an example definition!

File: hitchhiker/knowledge-base/classes/Customer/class.vkl

kb {
class Customer {
name.en: "Customer"
/* ... */


// Class indicating whether a customer is a private or company customer,
// used to define the subclasses
class Segment { /* ... */ }

// Subclass for companies
subclass Company_Customer {
// Subclasses often use a display_name instead of name
// to avoid conflicts with existing concepts,
// in this case the "Company" segment entity
display_name.en: "Company Customer"

// The subclass is defined as all customers that are in the "Company" segment
definition: "this.Segment = kb.Customer.Segment.Company"


// Nested attributes in the subclass are
// only available if the condition in definition holds
number CompanySize { /* ... */ }
class Industry { /* ... */ }
}

// Subclass for private customers
subclass Private_Customer {
display_name.en: "Private Customer"

definition: "this.Segment = kb.Customer.Segment.Private"

date Birthdate { /* ... */ }
}
}
}

The main part of a subclass definitions are the definition and the nested attributes, with the definition determining for which entities of the class the attributes make sense.