Extract classes

In some ontologies, classes have associated with them many properties, making the model hard to maintain and redundant. For example, if you have a class Person with properties such as firstName, lastName, street, zipCode, town, then you may consider to split the class into two, yielding a class Address with street, zipCode and town bundled together. Such transformations are difficult or impossible to do manually, because it involves converting all instance data correctly.

TopBraid Composer provides a refactoring to split classes into two. The results of this refactoring can be chained together to do even more complex transformations. The refactoring Extract Class... is available for classes that are in the domain of at least one owl:DatatypeProperty. It is then accessible from either the Resource menu, or the drop-down menu in the upper right corner of the class form.

In the example below, we start with a similar ontology that has been created from a spreadsheet, as described on the Import Spreadsheets page. The input ontology looks as shown below. As you can see, the class Person has six datatype properties attached to it (via the rdfs:domain property). The ontology also defines three instances of Person, with values for each property.


In order to separate concerns, we want to bundle four of the properties into a new class Address, and let the system create an association hasAddress between Person and Address. To do so, we select the class Person and select Model/Extract Class..., taking us to the following wizard.


In this wizard, you can specify the names for the new class and its association, as well as a pattern to create the names of the new instances. This name can use place-holders for the property values, using their relative index among the selected properties. In the example above, the names of the new instances will consist of the town and the state, separated by a dash (-).

The resulting class structure will look as follows:


The system will also generate three instances of the new class Address. You can easily imagine that a similar refactoring can be applied again, for example to merge town and state into a single entity. In this case, the system would try to merge addresses from the same town and state.