Modeling question: extending the actor-movie case (ternary relations)

333 views
Skip to first unread message

Willem Salembier

unread,
May 21, 2012, 7:12:40 AM5/21/12
to ne...@googlegroups.com
I'm learning about graph databases and have some questions about modeling. I examined the actor-movie example in the neo4j documentation, but wonder what to do if it gets a little bit more complicated, eg the case of actors appearing in theater plays?

With the actor-movies case the role relationship is ideal to put any properties like the character name. With theater plays, a character can be played multiple times in multiple productions. It's a ternary relationship. And because all relationships in neo4j are binary relations, some relationships have to be 'entitized'.

I tried to do this exercise in the attached file (acting.png)
- What's your feedback about this model? The entity ActingPrestation seems a little artificial to me.
- What about query performance? Quering all plays an actor played in becomes a lot harder. Should we duplicate the relationship and maintain a direct relationship between actors and plays or is it no deal for a graph database?


acting.png

Mattias Persson

unread,
May 21, 2012, 9:11:35 AM5/21/12
to ne...@googlegroups.com
For figuring out which plays an actor played in is just like (relationship type names not thought through):

start actor=...
match actor-[ACTOR_PRESTATION]->prestation-[CHARACTER_PRESTATION]->play
return play;

right? To me this feels very much like a graph problem :)

2012/5/21 Willem Salembier <willem.s...@gmail.com>
Don't duplicate data like this. If it ever becomes a problem then maybe, but I don't think it will be.



--
Mattias Persson, [mat...@neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com

Willem Salembier

unread,
May 21, 2012, 11:54:25 AM5/21/12
to ne...@googlegroups.com
Exactly, the query isn't complicated and the better if performance should be no issue. I only wonder if there is another way to model 'ActingPerformance' because to me it shouldn't be a node but a relation.

Mattias Persson

unread,
May 21, 2012, 2:28:51 PM5/21/12
to ne...@googlegroups.com
It's the standard way of modeling a thing like this, where you in essence have a relationship with more than two nodes attached to it (hyper edge).


Den måndagen den 21:e maj 2012 skrev Willem Salembier<willem.s...@gmail.com>:
> Exactly, the query isn't complicated and the better if performance should be no issue. I only wonder if there is another way to model 'ActingPerformance' because to me it shouldn't be a node but a relation.
>

Reply all
Reply to author
Forward
0 new messages