Set domains and ranges

Domains can be set in two ways:

  1. When editing a class in the Resource Editor you can define a domain the class belongs to using: Drag and drop a property from the Properties View into the Domain View.
  2. When editing a property, pick a class from the Classes View and drag it onto the rdfs:domain label on the form. Alternatively, add an empty row and type the name of the class (with auto-completion for your convenience).

To set a range:

 

Using Domains and Ranges versus Local Restrictions

Keep in mind that domains and ranges 'belong' to a property rather than a class. And they are global. In other words, any time a property is used in a statement, the following will happen:

It is important that properties are reused with care, especially in situations when multiple ontologies may be merged:

If your target deployment environment will have an OWL inferencer, consider not setting any domains and ranges and using local restrictions instead. Likewise, if you are using SHACL then the use of domains and ranges should be limited to its official RDFS interpretation, i.e. for the purpose of inferencing and not constraint checking.

If a class is in a domain of a property, it does not mean that its subclass is in the domain of the property. RDFS inheritance does not work as object oriented inheritance. If you want to ensure that subclasses are in the domain of the property, use local restrictions.

 

Using Domains and Ranges with Subproperties

Domain and range of a parent property should be a parent class of the domains and ranges of the child property. Even if they are not, as soon as instance data that uses the property is added the ontology, these inferences will be made. Consider the following example:

In this example declaring that hasParent has Person in the domain and range, would be redundant. No new conclusions (inferences) would result from it.

It is therefore often advisable to leave domains and ranges of a parent property empty. This is a good practice that will ensure that your ontology is consistent and easy to maintain.