I'll address the first example you posted:
(u:User)-[:LIKES]->(p:Post)
(u:User)-[:LIKES]->(c:Comment)
vs
(u:User)-[:LIKES_POST]->(p:Post)
(u:User)-[:LIKES_COMMENT]->(c:Comment)
This is essentially fine-grain vs. coarse-grain relationship ,as described in the Graph Databases book (ch. 4 - Building a Graph Database Application). Think about your usage:
- If you always want to query what a user likes, regardless whether it's
Post
orComment
, thenLIKES
works great. - If you want to search specifically for a user's
Posts
, or a user'sLikes
, then fine-grain relationship types such asLIKES_POST
work great. If you stayed with the more genericLIKES
, you'd need to pay attention to the entity types in your filtering. And... if this list grows over time, you'll need to modify your queries to include the new types (and if this type list is unbounded, it could get a bit cumbersome). - If you often mix it up, you may want to consider having both fine- and coarse-grain relationships between these nodes.