简体   繁体   中英

Property graph (Neo4j) design: Single node with multiple relations or new nodes for each event occurence?

Let us say I've two Leagues L1 and L2. Each league can have multiple rounds like Playoffs, Quarterfinals, Semifinals and Finals. Moreover, I also need to represent the happens_after fact like Quarterfinals happens after Playoffs, Semifinals happens after the Quarterfinals and Finals happens after the Semifinals.

Questions

Should my graph have one node for each of these rounds and each League should link to these rounds? This way we are just creating new relationships (eg both L1 and L2 will have a relationship to Playoffs) but there is only one Playoff node. However, this limits the happens_after relationship because some leagues can have more rounds (for eg Round 2 can come before Quarterfinals). Is there a better way to represent this?

Use-cases

  1. Need to be able to find all the rounds of a given league.
  2. Need to be able to find the order of all the rounds of a given league and the dates each of these happened.

EDIT

在此处输入图片说明

In general everything that has an identify on its own should become a node. Relationships tie the "things" together.

Not sure if I fully understand your domain. L1, L2 and each round would be nodes. The relationship league -> round indicates that a given league takes part in the round.

The temporal order within the rounds can be modeled by having BEFORE and/or AFTER relationships among them. This way you build a linked (or a double linked) list of rounds. Another way to express temporal order would be to store a indexed timestamp property for the round. If you're just interested in before or after and not on absolute time, the first approach (linked list) seems to fit better.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM