I am trying to express this one:
Manchester distance from London is 335 km.
I have created class city and now I am thinking to create and objectProperty hasDistance with Domain City and Range City.
But where can I declare the real distance for it?
This is in actual fact an example of an n-ary relation. In such a case the relation is modelled as a class rather than a property. For this purpose, let us assume we introduce a class DistanceBetweenTwoCities
. Hence, one way to model this is as follows:
Class: City
Class: DistanceBetweenTwoCities
ObjectProperty: hasCity1
Domain: DistanceBetweenTwoCities
Range: City
ObjectProperty: hasCity2
Domain: DistanceBetweenTwoCities
Range: City
DataProperty: hasDistance
Domain: DistanceBetweenTwoCities
Range: xsd:integer
To now state the distance between London and Manchester:
Individual: distanceLondonToManchester
Types:
DistanceBetweenTwoCities
Facts:
hasCity1 london,
hasCity2 manchester,
hasDistance 335
Individual: london
Types: City
Individual: manchester
Types: City
Note: Strictly speaking it is not necessary to introduce two different properties hasCity1
and hasCity2
. We could have used only hasCity
. I only introduced 2 properties to make the n-ary relation a bit more obvious.
Update 20190320
If you have another distance you have to present you can add another individual of type DistanceBetweenTwoCities
:
Individual: distanceLondonToAthens
Types:
DistanceBetweenTwoCities
Facts:
hasCity1 london,
hasCity2 athens,
hasDistance 3000
Individual: athens
Types: City