0

I wanted to know that am I implementing a Graph DB scanerio correct or not. I am trying with Titan Graph Database and neo4j

user-1 has asked a question this is question1 to user-2

user-2 replied to that question

user-3 also replied to that question

Here is the picture How i am doing this. Am i doing it correct or there is some space of improvement??

enter image description here I want following query answer from this picture:

  • Question asked by a user
  • Question asked to a user
  • All reply to a question.
  • Who replied to a question (here is my doubt with the above picture because I dont have direct connection to user who replied. One solution that I am thinking will be a edge from user vertex to question vertex but i am not sure is it efficient or not)
Manish Kumar
  • 10,214
  • 25
  • 77
  • 147
  • I think i am going right after seeing this http://1.bp.blogspot.com/-J0yE-6wPAbY/URJVjDO9ETI/AAAAAAAAI28/BTuJDJw5uWA/s1600/SIB+schema+v1.jpeg – Manish Kumar Feb 07 '14 at 14:34

1 Answers1

3

I think your model is sensible

I show some sample Neo4j Cypher statements for your questions:

Questions asked by a user
MATCH (u:User {name:{name}})-[:ASKED]->(q:Question) RETURN q
Question asked to a user
MATCH (u:User {name:{name}})<-[:ASKEDTO]-(q:Question) RETURN q
All reply to a question.
MATCH (a:Answer)<-[:REPLYTO]->(q:Question {id:{question}) RETURN a
Who replied to a question
MATCH (u:User)-[:REPLY]->(a:Answer)<-[:REPLYTO]->(:Question {id:{question}) RETURN a,u

Feel free to check out the Neo4j online course for details.

Michael Hunger
  • 41,339
  • 3
  • 57
  • 80