Get in touch
Get in touch

Subclassing and inheritance

Sometimes the Concept type you want to give your data shares a common pattern with other types. In Data Graphs it is possible to make types that share some common parent type. This is sometimes referred to as classes being a subclass of another class.

This allows you to share common properties from the parent class as well as benefiting from the ability to facet on both the child and parent class.

For example you might have a vehicle Concept type that has properties for name and manufacturer. You could then define more specific Concept types for planes and motor vehicles. These might have their own set of specific properties, wing length for planes or transmission type for motor vehicles, but they will inherit the properties of the vehicle Concept type as well.

In addition when you search for anything made by a manufacturer you could see any type of vehicle plane of motor vehicle.



Planning your Concept type hierarchy

If you have already designed your model it is advised to define your Concept types in Data Graphs starting from the top down. Start with the parent type and work down to define more specific Concept types. When it comes to creating a new type it is as simple as selecting from the existing parent types in the drop down list. By defining your parent types first they will be available to select when it comes to defining more specific Concept types.

Creating subclasses

You create a subclass or a sub-type when creating a Concept type schema in a Dataset. After naming your Concept, you have the option of choosing a Parent Type for the Concept you are defining.

By selecting the Include {type} properties option, your new subclass will inherit (re-use) the properties from the parent type. This is most likely what you will need to.

Managing types

The Manage Types screen allows you to see a visual representation of your current type hierarchy. This view is accessible from the main account menu in the navbar called Manage Types. Within this screen you can remove a type that you no longer require or created incorrectly in your type hierarchy.

Transitive class inference

When you create a subclass type, Concept relationships become class structure aware, with transitive inference. When a Concept property defines a relationship to another Concept type/class the UI allows you to select Concept instances of that type and all its subclasses. For example, if you create a class Football Team that is a sub-class of Organization, and you then create a property on a Concept that references an Organization, as Football Team is a sub-class of Organization, football teams can also be assigned to that property. Search facets and API queries also obey the usual semantics of transitive inference across a class hierarchy.