smells like sql spirit

61 views
Skip to first unread message

gmail

unread,
Oct 7, 2012, 8:21:58 AM10/7/12
to ne...@googlegroups.com
hi,

i have a modelling problem, that reminds me of fk-tables in RDBMS. i
think i might be missing something obvious.


my model looks like:

team1-[:IS_PARTICIPATING_IN]->m1<-[:IS_PARTICIPATING_IN]-team2
team1-[:IS_PARTICIPATING_IN]->m2<-[:IS_PARTICIPATING_IN]-team3
team1-[:IS_PARTICIPATING_IN]->m3<-[:IS_PARTICIPATING_IN]-team4


(m1, m2, m3 are sports matches)


i want to introduce user rating, so that a number of users can rate a
given team participating in a given match.

so my first thought was to introduce a User node and a HAS_SEEN
relationship:

approach A
----------
# first sports match (User 1)
user1-[:HAS_SEEN]->team1
HAS_SEEN relationship properties could be {stars: 5, sportsmatch:1}

user1-[:HAS_SEEN]->team1
HAS_SEEN relationship properties could be {stars: 6, sportsmatch:1}


# second sports match (User 1)
user1-[:HAS_SEEN]->team1
HAS_SEEN relationship properties could be {stars: 7, sportsmatch:2}
user1-[:HAS_SEEN]->team3
HAS_SEEN relationship properties could be {stars: 8, sportsmatch:2}


# first sports match (User 2)
user2-[:HAS_SEEN]->team1
HAS_SEEN relationship properties could be {stars: 9, sportsmatch:1}
user2-[:HAS_SEEN]->team2
HAS_SEEN relationship properties could be {stars: 10, sportsmatch:1}


in the above model the relation between user rating and
team-participating is leveraged at the HAS_SEEN property level. ugly.



approach B
----------
i have also played with the introduction of an additional "Rating" node:

user1-[:HAS_CREATED_RATING]->rating->[:RATING_OF_TEAM_IN_A_MATCH],
rating->[:IS_A_RATING_OF_TEAM]-team1,
rating->[:IS_A_RATING_OF_MATCH]-m1,

RATING_OF_TEAM_IN_A_MATCH relationship properties could be {stars:5}




it feels like what i really want is to connect a user rating directly to
en existing relationship (eg. the IS_PARTICIPATING_IN relationship in
team1-[:IS_PARTICIPATING_IN]->m1 ) since the user is not really rating a
team or a match but a team participating in a match.


any pointers to better approaches would be much appreciated

thanks
./allan

Peter Neubauer

unread,
Oct 7, 2012, 11:20:46 AM10/7/12
to ne...@googlegroups.com
Allan,
sounds like you should then model the TEAM-PARTICIPATING-IN-MATCH as
its own node, and attach the ratings to that one? Something like

u1-[:RATING{stars:5}]->participation_team1,
team1-[:PARTICIPATE]->participation_team1-[:MATCH]->match1,
u1-[:RATING{stars:4}]->participation_team2,
team2-[:PARTICIPATE]->participation_team2-[:MATCH]->match1

WDYT?

Cheers,

/peter neubauer

G: neubauer.peter
S: peter.neubauer
P: +46 704 106975
L: http://www.linkedin.com/in/neubauer
T: @peterneubauer

Neo4j 1.8 GA - http://www.dzone.com/links/neo4j_18_release_fluent_graph_literacy.html
> --
>
>

Rick Otten

unread,
Oct 8, 2012, 9:04:53 AM10/8/12
to ne...@googlegroups.com
Don't fans watch matches rather than teams?
fan1-[:has_seen]->m1 ?

It sounds like you want to apply a 'weight' (rating) of some sort to the team nodes so that you can predict future matches, or at least advertise "the fans' choice" for the better team in the match.

Perhaps -- fan1-[:rate]->team1 (if fan1 has seen a match where team1 played)

Team1's total and aggregate rating is collected from the inbound [:rate] relationships.
--


Rick Otten

unread,
Oct 8, 2012, 11:59:07 AM10/8/12
to ne...@googlegroups.com
Instead of saying:
" Team1's total and aggregate rating is collected from the inbound [:rate] relationships."

I meant to say:
"Team1's total and average ratings could be collected from a weight/(star number) property on the inbound [:rate] relationships.

I also meant to note that fan's could 'follow' teams, which would enable an application to do things such as alert them to upcoming matches, report on rankings and scores and match history, and that sort of thing.

So a given fan might have two relationships to a team - "[rate:]" and "[follows:]" and another relationship to matches "[watched:]".

I meant to say all this, but got interrupted in the midst of my last sentence and hit 'send' instead of finishing my thoughts. Thanks for letting me finish.
--


Peter Neubauer

unread,
Oct 8, 2012, 6:28:01 PM10/8/12
to ne...@googlegroups.com
Rick,
yes, I think users would WATCH matches, but RATE the participation
(nodes) of the teams. I think you could then do

u1-[:RATING{stars:5}]->participation_team1,
team1-[:PARTICIPATE]->participation_team1-[:MATCH]->match1,
u1-[:RATING{stars:4}]->participation_team2,
team2-[:PARTICIPATE]->participation_team2-[:MATCH]->match1,
u1-[:WATCHED{rating:3}]->match1

and maybe even attach a rating to that relationship. WDYT?

Cheers,

/peter neubauer

G: neubauer.peter
S: peter.neubauer
P: +46 704 106975
L: http://www.linkedin.com/in/neubauer
T: @peterneubauer

Neo4j 1.8 GA - http://www.dzone.com/links/neo4j_18_release_fluent_graph_literacy.html


> --
>
>

gmail

unread,
Oct 10, 2012, 4:51:32 PM10/10/12
to ne...@googlegroups.com, Peter Neubauer
hi rick, peter,

many thanks for great ideas and suggestions!

i think i will start off something along your suggestion peter, with a
participation_team node concept. only i think i will name it slightly
different:

u1-[:RATING{stars:5}]->team1,
squad1<-[:IS_BASED_ON]-team1-[:IS_PARTICIPATING_IN_MATCH]->match1,
u1-[:RATING{stars:4}]->team2,
squad2<-[:IS_BASED_ON]-team2-[:IS_PARTICIPATING_IN_MATCH]->match1,
u1-[:WATCHED{rating:3}]->match1


and furthermore for player ratings:

u1-[:RATING{stars:7}]->player1,
person1<-[:IS_IN_REAL_LIFE]-player1-[:IS_PLAYING_A_MATCH_FOR]->team1,
u1-[:RATING{stars:8}]->player2,
person2<-[:IS_IN_REAL_LIFE]-player2-[:IS_PLAYING_A_MATCH_FOR]->team1,
squad1<-[:IS_BASED_ON]-team1-[:IS_PARTICIPATING_IN_MATCH]->match1,

etc.

thanks once again

./allan
Reply all
Reply to author
Forward
0 new messages