Ontology exercises, set 2

Exercises for membership relationships

Each of the examples below has three terms that represent classes. Identify the “has member” and “has subclass” relationships among the three terms. (Answers are below.)

1) Index finger, Set of fingers, Finger

2) Football player, Quarterback, Football team

3) Blue crayon, Crayon, Set of crayons

4) Fork, Set of silverware, Piece of silverware

The Cupcake Ontology

This exercise shows how the principles of building an ontology can be applied to a different domain.

Imagine that you have been asked to create an ontology for the domain of cupcakes. The users of the ontology need to be able to describe different types of cupcakes and what makes up these cupcakes.

cupcake image and recipe

1) Create the class hierarchy. The top class can be called “Cupcake entity”. The subclasses should account for types of cupcakes (such as vanilla cake with vanilla frosting, vanilla cake with chocolate frosting, and chocolate cake with chocolate frosting), types of cake, types of frosting, baking liner, and types of ingredients (see illustration of recipe card; chocolate cake and chocolate frosting contain both vanilla and cocoa). It is helpful to visualize the classes using an indented hierarchical list (where subclasses classes are indented). Here is a partial diagram to help you begin:cupcake partial class hierarchy

2) Use a “has part” relationship to model the relationships between types of cupcakes, types of cake, types of frosting, and baking liner.

3) Now model the relationships between the cake, frosting, and ingredients, again using the “has part” relationship (or you might use the more specific “has ingredient” relationship). You may ignore information about the amount of the ingredients used.

4) Once you have this basic structure for your ontology, think about how you could expand it. Can you account for edible vs. non-edible parts? How might a class for the uncooked batter fit into the ontology, and what would be its relationship to the cake? Could an ontology describe items such as sprinkles or candles?


Exercises for membership relationships

1) Set of fingershas memberIndex fingerhas subclassFinger

2) Football teamhas memberQuarterbackhas subclassFootball player

3) Set of crayonshas memberBlue crayonhas subclassCrayon

4) Set of silverwarehas memberForkhas subclassPiece of silverware

Exercises for the cupcake ontology

1) Diagram of the class hierarchy: cupcake class hierarchy

2) Diagram showing the “has part” relationships among the types of cupcakes, types of cake, types of frosting, and baking liner: cupcake parts diagram

3) Diagram showing the relationship “has ingredient”: cupcake ingredients diagram

4a) To account for edible and non-edible layers, you could add Edible part and Non-edible part as subclasses of Cupcake entity.

4b) To account for uncooked batter, you could use a relationship such as Battertransforms intoCake.

4c) You could model sprinkles and candles in several ways. One approach is to create new subclasses of Cupcake entity called Sprinkles and Candle. Or you could create a class Topping as a subclass of Cupcake entity, and place Frosting, Candle, and Sprinkles as subclasses of Topping.