Model relationship state through different labels or through relationship parameters?

Hey there!

I am currently wondering what the recommended approach is to store the state of a relation between two nodes.

For the example, let us set the following social network-y idea:

  1. Nodes are users
  2. Friendships are relations
  3. Friendships need to be requested and can then be accepted or denied.

Point 3. introduces a "state" the friendship can be in (requested, accepted, denied).

My initial approach was to use different relation labels (:friendship_requested, :friendship_denied, :friends). This makes querying for specific states very easy.

But now I start to wonder if it would be better to just have one type of relation, :friends, and add a parameter to store the friendships state.

How would you recommend to model relations with a state in the graph?

This is an excellent question, and one that depends on the kinds of queries you want to run. For instance, as you stated, if you want to see friend requests vs friends vs denied requests, creating different relationships for each status makes query performance pretty fast. However, if you just want to find all connections a user has (no matter the request status), then having it as a property is just fine.

This is where modeling decisions can differ depending on the questions you want to ask of the data. It allows you to organize the data to optimize the queries you want to run. Hope this helps!