Rafael T
Rafael T

Reputation: 15689

neo4j modell one Relationship with n properties vs n Relationships with one property

I want to build up a graph DB containing Station nodes and Line Relationships between them. Stations are connected with Lines. The Problem is: a Line connects Stations only at certain times. I'm now wondering if I should connect a Station with one Line Relationship putting the times as Parameters of this line, or to connect a new Relationship between two Stations for every time.

The goal is to find the fastest path between two Station nodes at a certain time.

What is the best way to modell such kinds of Relationships?

Upvotes: 0

Views: 62

Answers (1)

Michael Hunger
Michael Hunger

Reputation: 41706

Usually you can break them down by day of the week or workday/weekend. So they are just repeating times across the year. That would narrow down the amount of relationships you need, or?

And only update that information when the schedule changes, or there is some maintenance.

So I'd try to do one relationship per category and probably put the times into an attribute. Another interesting option would be to divide the day up into 5 minute segments (i.e. at a frequent line you get at most 288 rels for every 5 min segment). Name the rel-types according to the segment and have the concrete time as another attribute. So you can do a rough, good enough path finding by just looking at the rel-types. And then narrow it down to the best fit of the best rough results by looking at the concrete times.

Oh, there has been some work from Thoughtworks modeling Manchesters public transport system (Tramchester). There have been several recorded presentations about it.

Upvotes: 1

Related Questions