SKOS has the notion of concept and concept schemes, which can be roughly used to model enums known from standard programming languages. Concepts can also be defined to be wider or narrower than each other, roughly equivalent to bit flags enums.
Assuming one would like to describe something like cardinal directions, the following is possible:
<CardinalDirections> a skos:ConceptScheme .
<north> skos:inScheme <CardinalDirections> .
<east> skos:inScheme <CardinalDirections> .
<south> skos:inScheme <CardinalDirections> .
<west> skos:inScheme <CardinalDirections> .
Yet enums are usually also part of the type system in various languages, so I could also choose this interpretation:
<CardinalDirection> a rdfs:Class .
<north> a <CardinalDirection> .
<east> a <CardinalDirection> .
<south> a <CardinalDirection> .
<west> a <CardinalDirection> .
So, a) is there any benefit of using one model instead of the other? And b) does it make sense to combine them?
<CardinalDirection> a rdfs:Class , skos:ConceptScheme .
<north> a <CardinalDirection> ; skos:inScheme <CardinalDirection> .
<east> a <CardinalDirection> ; skos:inScheme <CardinalDirection> .
<south> a <CardinalDirection> ; skos:inScheme <CardinalDirection> .
<west> a <CardinalDirection> ; skos:inScheme <CardinalDirection> .
In programming an enum is a unique type of class where the instances of the class is predefined and final. That is, new instances cannot be added to an enum.
Strictly speaking I do not think that what you refer to as representing an enum in RDF is in fact an enum. Rather, it is a number of instances of the same class. In particular, there is nothing that prohibits making the following statement:
To see this more clearly, consider the following example:
Clearly the
Person
class is not an enum.In RDF there is no way to prohibit adding additional instances to a class as is needed for defining an enum.
If you want to define an enum, you will need to use OWL. Then you could define an enum in the following way:
where you define, for example
:East
, as follows:When will you define an enum in this way? When you plan to run an OWL reasoner over your schema or data. In that case adding
:apple a :CardinalDirection .
will result in an inconsistency.If you do not require running a reasoner, there is no reason to consider using enums.