Displaying N-ary relations in Protege forms    (46I)

General issue    (46J)

Suppose we want to represent the following fact: Steve has temperature, which is high, but falling. This sentence represents an n-ary relation: relation between Steve and two values for his temperature. As the note on representing N-ary relations describes, one common way to represent such a relation is by creating a special relation class. In this case, we can create a class Temperature, with two properties, temperature_value and temperature_trend to store the two components of the temperature relation.    (46K)

However, when we use the Protege form for acquiring the information for individual, we need to open up a separate window to enter the temperature information:    (46L)

http://protege.cim3.net/file/pub/images/misc/temperature_standard_widget.jpg    (46M)

The instance of a temperature relation is a separate instance and thus brings up its own window for editing.    (46N)

However, we can use InstanceRowWidget for single-cardinality slots and InstanceTableWidget for multiple-cardinality, to view exactly the same two instances in the following way:    (46O)

http://protege.cim3.net/file/pub/images/misc/InstanceTable.jpg    (46P)

Much nicer, no? You can choose different colors for text in different columns and you can enable in-place editing to allow something like this:    (46Q)

http://protege.cim3.net/file/pub/images/misc/InstanceTableEditing.jpg    (46R)

You can use the same widgets and the same mechanism to include information about any related instance on the "parent" form; it does not have to be an n-ary relation.    (46S)

Solution    (46T)

Protege provides two widgets that enable you to show and edit the contents of related instances directly on the form for the "parent" instance. Here is how to do that in the temperature example above:    (46U)

  1. Go to the Forms tab and select the Person class. We will edit the form for this class to get the information for the temperature slot appear directly on the form for instances of Person.    (46V)
  2. Select the slot temperature    (46W)
  3. Select the InstanceRowWidget from the pull-down list at the top right corner of the form. If the slot has cardinality multiple, select InstanceTableWidget    (46X)
  4. While temperature is still selected, double-click on the selected area. This action will bring up the form to configure the widget for the temperature slot.    (46Y)
  5. Select the tab for "Define columns...". Here you will be able to select which columns you want to appear in the table (see the figure above), in what order, and what labels you want on the columns.    (46Z)
  6. Place the cursor in the editable area in the third row of the column to select the appropriate column. Use the icons at the top-right corner of the table to remove and add columns. Unfortunately, you cannot drag columns to change their order -- you will need to remove and add columns to get the desired order. You will be given the choice of all the slots that the related class (in this case, Temperature) has in the list of available columns.    (470)
  7. Go to other tabs to configure the rest of the widget. For example, you can enable or disable in-place editing for cells.    (471)
  8. Click "OK"    (472)

You are done. Now create an instance of the class Person and look at the form. It looks exactly as the second figure above, You can select any cell and edit the values right there (if you enabled in-place editing). You can also click the "View" button to bring up the instance corresponding to the row in a separate window (similar to the first figure above).    (473)

Back to ModelingTipsAndTricks page    (474)

-- NatashaNoy    (475)