Вопрос

I am trying to model soccer matches and the referees and teams that play in them. I want to create nodes based on matches, referees, and players and am not clear on the best approach to model them? That is should I model it after cities, matches? Do I create a root node Id etc?

The kind of information I would looking for later would be stuff like:

1). Show all the matches for a particular referee (could be in multiple cities) 2). Show all matches where referee worked and home team won 3). show all referees that that have the highest count of wins for the home team? 4). show most active refereess in a particular city

As you can see there are all sorts of questions and for someone new this can be a little overwhelming. While I am reading some books, I wanted to see if any experts could help me in the scenario above. Again not sure if I need a root node that connects all the cities and referees and matches or just keep things independent. Your feedback would be most appreciated.

Это было полезно?

Решение

One of the possible models that at the moment seem to satisfy the queries you've posted:

(Team)-[:PLAYS]->(Match)

(Match)-[:HAS_REFEREE]->(Referee)

(Match)-[:PLAYED_IN]->(City)

The PLAYS relation could have a property to indicate if the team was the home team. You could also have a property on the PLAYS relation to indicate whether that team won or not. Or if winning is a big part of what you're looking for, you can create an extra relation such as (Team)-[:WON]->(Match) (though then you need to think about how to model draws. The absence of a WON relation on either of the two teams for a match could indicate a draw maybe).

1) All matches for a particular referee: Start at the referee, traverse through the Match to the Cities. You might index some unique property of the referee to be able to look him up quickly

2) All matches where the referee worked and the home team won: Start at the referee, find all his matches, filter on the WON relation/property and the home team property

3)All referees that have the highest count of wins for the home team: Same as above, start at all referees

4)Most active referees for a city: Start at the city, find all matches and their referees

You might move things around a bit depending on more questions that you want to answer (especially home team properties, WIN/LOSE relations or properties etc.)

And I don't think you need the root node at all. You can index all matches/cities/referees etc if you want to find all of them

Другие советы

I've done some modelling of football/soccer matches which might be interesting to look at - http://staging.thinkingingraphs.com/

Mostly the same as what Luanne said although I've got specific relationship types indicating which team played at home and away. I've been writing up what I discovered while building out the model here as well - http://www.markhneedham.com/blog/tag/neo4j/page/2/

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top