Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-05-2023 11:12 PM
hi im new here and this is my first post. im trying to build an app where sharing post between friends and friend of friend
for ex consider this there are users A,B,C and D and each user can create posts.
Now User A and B are friends and User B and C Friends. so if A create a Post, it can be seen by B(friend ) and C (friend of friend). but not by user D.
so is it possible to increase the degree also like if C and D are friends . then can the post created by A can be seen by D (friend of a friend of a friend)
can i do this in neo4j and will it be efficient
01-06-2023 04:13 AM - edited 01-06-2023 04:17 AM
This would be fairly easy with neo4j. You could have a model with nodes for Person and Post. A post can be related to its author with a POSTED_BY relationship. People that are friends can be related with a FRIEND_OF relationship. I would assume the friendship is bidirectional, thus the relationship direction is not relevant. Given a user, you can find all the friends, friend of friends, etc to any depth. Assuming just friend and friend of friends, you can find these for ‘Tom’ with the following, where ‘f’ are the related friends of Tom.
match(n:Person{name:’Tom’})
match(n)-[:FRIEND_OF*2]-(f:Person)
return f
if you want the posts of these related friends, then use the following:
match(n:Person{name:’Tom’})
match(n)-[:FRIEND_OF*2]-(f:Person)<-[:POSTED_BY]-(p:Post)
return p
you can increase the degree by increasing the ‘2’ following the asterisk.
This can be done much more efficiently and less complicated than could be done in a relational database. The main reasons being the entities are linked by relationships that can be quickly traversed, compared to a relational database were you have to perform joins for each degree of separation. Performance would degrade quickly and complexity would also increase substantially as the degree increased.
the graph model is made for this type of problem.
01-08-2023 09:02 PM
thanks. im a non technical developer. already have my app published without knowing any code entirely developed by me. im using various no code tools. so is there such tools available for neo4j , where i can generate queries,filters and api's
01-09-2023 01:26 AM
Sorry, not that I am aware of.
All the sessions of the conference are now available online