graphvaticle-typedb

Why does Grakn use noun semantics on relations instead of verbs?


I was going over some of the docs here.

I was curious why Grakn opts to indicate relations using noun semantics rather than verb semantics? In most of the other graph work and research I’ve covered, it usually makes sense to think that two entities (nouns) are linked by a verb e.g. person worked at company. Indeed, for a few entities that I am dealing with, it is a bit difficult to reason about the relationships as nouns for example if artist remixed track.

I’m inclined to use verbs as relations but I wonder if that is not how I should be thinking about it in a Grakn setup. Are there eventual difficulties I can expect to face if I decide to use verb semantics?


Solution

  • Typically, graph databases use directed edges to represent binary relations. Under those circumstances it makes sense to use a verb to describe a relation, since verbs often indicate a directional action between a subject and an object.

    Grakn is a knowledge graph, which works differently. This is because relations in Grakn act as hyperedges. This means that there can be more than two participants (called roleplayers) in a relation. This is great for flexible modelling, but it can break the verb naming convention.

    To work from your example, rather than artist remixed track, we could (very conveniently in this case) use the noun remix as the relation. Taking a guess at the domain model, an artist remixes a track, and as a result they have created a new track. That’s a great opportunity for a ternary (3-way) relation in grakn. The model for that would be as follows:

    define 
    remix sub relation,
       relates original-track,
       relates remixed-track,
       relates remixing-artist;
    
    track sub entity,
       plays original-track,
       plays remixed-track;
    
    artist sub entity,
       plays remixing-artist;
    

    Once the schema above has been defined in Grakn, we can add a remix instance connecting two new tracks and a new artist like so:

    insert 
    $o isa track, has name "Brimful of Asha"; 
    $rt isa track, has name "Brimful of Asha (Norman Cook Remix)"; 
    $a isa artist, has name "Norman Cook"; 
    $r(original-track: $o, remixed-track: $rt, remixing-artist: $a) isa remix;
    

    It has then proved useful to use a noun for the relation because it doesn’t connect any of the 3 roleplayers it can have in a binary way. Instead we have named the concept that sits in-between the two tracks and the artist.

    In this way we see that the relation nicely describes the (undirected) link between any pair of the roles:

    original-track <-remix-> remixed-track
    original-track <-remix-> remixing-artist
    remixed-track  <-remix-> remixing-artist
    

    We can see that using remixed in place of remix wouldn't work so well, it would try to add direction to these links where there is none.

    Grakn's data model can be extended on-the-fly. Therefore even if you start with a binary relation, should you later add more roles, making it ternary or N-ary, verb naming will no longer make sense.

    It’s not always easy to name relations with nouns. My suggestions are: