1
votes

I'm trying to design a Neo4j graph database, and I will illustrate my specific requirement. I'm designing an app that allows users to collaborate on the books and magazines they have read. Requirements:

  1. The same Book can be read by multiple people

  2. The order in which a specific person reads the books is important. For example, I want to be able to represent that Person A read Books B1 and B2 in that order, while Person B may have read Books B3, B2 and B1 in that order.

    I'm thinking of having nodes representing a Book, Magazine, Person, etc.

What is the best way to ensure the order/sequence information? A couple of options I thought about:

  1. Store a order ID or timestamp in the relationship between a Person and a Book node and use that to query all Books read by the person in the right order.
  2. Store a Next/Previous relationship between Book nodes, but this approach will not work because the order can vary depending on which person read the books.
1

1 Answers

2
votes

To me this is the way to go, easy and effective.

Store a order ID or timestamp in the relationship between a Person and a Book node and use that to query all Books read by the person in the right order.

Storing a Next/Previous relationship will not work, because you would have to save UserID in the NEXT relationship between books and that is just nonsense.