cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Capturing "has" semantics in graph model

I think one of the most difficult challenge is to capture colloquially "has " or "has a" relationship to proper verb based relationship.

My scenario is like following:
A Test is like an exam. Test consists of multiple questions.
User/Student takes a test, but answers individual questions.

  1. How should a Test be related with a question?
  2. How do we reflect that Test has a 1-to-many relationship with Question? Is there a way we show by relationship that a Test consists of an array of question?

This is the fundamental problem (capturing 'has a') bugging me. Any help would be appreciated.

3 REPLIES 3

Remember that relationships are best if we define them as verbs.

You are already answering your question. We can name the relationship as test HAS question, or test INCLUDES question, or test CONTAINS question. These are options, of course there are more valid ones that you can search by synonyms. At the end it all depends on the questions you want to answer and if it easier for you queries' understanding.

By creating relationships from a test to many questions, you are already representing such relationship. If you want to create a questions array of some test, you can include the nodes "Question" in an array using the function collect().

@alejandropuerto
The issue is that I was reading a book on graph data modeling and it mentioned that "has a" is not an ideal relationship. Relationship in a Graph database must be a verb.

That is why I mentioned alternatives, such as: INCLUDES, CONTAINS, COMPRISES, COMPREHENDS, etc. I hope these alternatives suits your model.