I want to make IMDB's characters/roles structure in Neo4j. I'll need labels Person, Movie and Character. Character, because a character can be in multiple movies, played by different people.
Without Character, it's easy:
(Person)-[:PLAYS_IN]->(Movie) But PLAYS_IN is a Character, so it would be something like:
(Person)-[:PLAYS_AS]->(Character)-[:PLAYS_IN]->(Movie) but that doesn't work, because it doesn't have a direct Person-Movie relationship. Without that, everyone who ever played Peter Parker, is in every movie that has a Peter Parker.
There must be a Person-Movie relationship, but also a Person-Movie-Character relationship. How? This could work, but that's just nasty:
(Person)-[:PLAYS_IN {uuid}]->(Movie), (Character {uuid}) because now I'm creating my own foreign key kind of relationship. That's very ungraphdb. But it works:
MATCH (p:Person)-[r:PLAYS_IN]->(m:Movie), (c:Character) WHERE c.uuid = r.uuid RETURN p, c, m by building a cartesian product =( which is very RDBMS, but not very graphdb. And I can't query Character-Movie or Character-Person, because that's not a real relationship.
How do I make a RDBMS link table with 3 foreign keys (movie_id, character_id, person_id) in Neo4j??
edit 1
The RDBMS equivalent:
movies (id, title) # e.g. Dragon Tattoo, or Spider's Web people (id, name) # e.g. Rooney Mara, or Claire Foy characters (id, name) # e.g. Lisbeth Salander roles (movie_id, person_id, character_id) # 2 rows with 1 distinct character_id 